I have the following scenario:
I have a dropdown list populated with the the top-level XML nodes' @number value. I have a GridView within a FormView bound to a datasource and set accordingly with bound values.
Question...
1. Am I on or off base with doing what I need to? Meaning, GridView? Or, is there some other appropriate Control that I should be using?
Do you have any examples showing how to accomplish this?
Here's my code (note that I call a MasterPageFile):
.aspx page
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" CodeFile="DBTasksxml.aspx.cs"
Debug="true" AutoEventWireup="true" Inherits="DBTasks" Title="DBTasksXML" %>
<asp:Content ID="content1" ContentPlaceHolderID="mainContent" runat="server">
<center>
<aspanel ID="mainpanel" runat="server" BackColor="White" BorderStyle="Solid" BorderWidth="1px"
Width="95%">
<br />
<aspanel ID="newbuildpanel" runat="server" BackColor="White" BorderStyle="Solid"
BorderWidth="1px" Width="700px">
<h1>
DB Task Tracking Tool</h1>
</aspanel>
<br />
Release Date: <aspropDownList ID="ReleaseDate" Width="180px" runat="server"
ToolTip="Available Releases" AutoPostBack="True" DataSourceID="releaseSelectDataSource"
DataTextField="id" DataValueField="id" OnSelectedIndexChanged="ReleaseDate_SelectedIndexChanged">
</aspropDownList>
<br />
<br />
<asp:FormView EnableViewState="true" ID="FormView1" runat="server" DataSourceID="formViewDS" Height="44px"
Width="94%">
<EditItemTemplate>
id:
<asp:TextBox ID="idTextBox" runat="server" Text='<%# XPath("releases/release[@id]") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<ItemTemplate>
<asp:GridView runat="server" ID="ItemsSummary" DataSource='<%# XPathSelect("//releases/release/..//td/.") %>'
AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" Width="90%"
HorizontalAlign="Center">
<RowStyle BackColor="#F7F7DE" />
<Columns>
<asp:TemplateField HeaderText="TD #">
<ItemTemplate>
<asp:TextBox Width="60" runat="server" ID="NameLabel" Text='<%# XPath("@number")%>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="x1a" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="x1aTextBox" Text='<%# XPath("x1a/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t1a" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t1aTextBox" Text='<%# XPath("t1a/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t1b" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t1bTextBox" Text='<%# XPath("t1b/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t2" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t2TextBox" Text='<%# XPath("t2/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t3" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t3TextBox" Text='<%# XPath("t3/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="prod" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="prodTextBox" Text='<%# XPath("prod/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="Notes for Prod" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="125" runat="server" ID="prodNotesTextBox" Text='<%# XPath("prod/notes")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<br />
</ItemTemplate>
<InsertItemTemplate>
id:
<asp:TextBox ID="idTextBox" runat="server" Text='<%# Bind("id") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
</asp:FormView>
<asp:XmlDataSource ID="formViewDS" runat="server" DataFile="dbtasks.xml">
</asp:XmlDataSource>
<br />
</aspanel>
<br />
<asp:XmlDataSource ID="tableDataSource" runat="server" DataFile="dbTasks.xml">
</asp:XmlDataSource>
<asp:XmlDataSource ID="releaseSelectDataSource" runat="server" XPath="releases/release[@id]"
DataFile="dbTasks.xml"></asp:XmlDataSource>
<br />
<asp:Label ID="message" runat="server" BackColor="Yellow" BorderColor="White" BorderStyle="None"
Font-Bold="True" Text="unset" Visible="False"></asp:Label>
</center>
</asp:Content>
codeBehind .cs page
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Windows.Forms;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.VersionControl.Common;
using Microsoft.Win32;
public partial class DBTasks : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
pageSetup();
}
}
protected void pageSetup()
{
}
protected void ReleaseDate_SelectedIndexChanged(object sender, EventArgs e)
{
System.Web.UI.WebControls.DropDownList dList = (System.Web.UI.WebControls.DropDownList)sender;
string releaseDate = dList.Text;
//MessageBox.Show(releaseDate);
string xPath = "releases/release[@id='" + releaseDate + "']//td";
MessageBox.Show(xPath);
}
}
I have a dropdown list populated with the the top-level XML nodes' @number value. I have a GridView within a FormView bound to a datasource and set accordingly with bound values.
Question...
1. Am I on or off base with doing what I need to? Meaning, GridView? Or, is there some other appropriate Control that I should be using?
Do you have any examples showing how to accomplish this?
Here's my code (note that I call a MasterPageFile):
.aspx page
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" CodeFile="DBTasksxml.aspx.cs"
Debug="true" AutoEventWireup="true" Inherits="DBTasks" Title="DBTasksXML" %>
<asp:Content ID="content1" ContentPlaceHolderID="mainContent" runat="server">
<center>
<aspanel ID="mainpanel" runat="server" BackColor="White" BorderStyle="Solid" BorderWidth="1px"
Width="95%">
<br />
<aspanel ID="newbuildpanel" runat="server" BackColor="White" BorderStyle="Solid"
BorderWidth="1px" Width="700px">
<h1>
DB Task Tracking Tool</h1>
</aspanel>
<br />
Release Date: <aspropDownList ID="ReleaseDate" Width="180px" runat="server"
ToolTip="Available Releases" AutoPostBack="True" DataSourceID="releaseSelectDataSource"
DataTextField="id" DataValueField="id" OnSelectedIndexChanged="ReleaseDate_SelectedIndexChanged">
</aspropDownList>
<br />
<br />
<asp:FormView EnableViewState="true" ID="FormView1" runat="server" DataSourceID="formViewDS" Height="44px"
Width="94%">
<EditItemTemplate>
id:
<asp:TextBox ID="idTextBox" runat="server" Text='<%# XPath("releases/release[@id]") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<ItemTemplate>
<asp:GridView runat="server" ID="ItemsSummary" DataSource='<%# XPathSelect("//releases/release/..//td/.") %>'
AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" Width="90%"
HorizontalAlign="Center">
<RowStyle BackColor="#F7F7DE" />
<Columns>
<asp:TemplateField HeaderText="TD #">
<ItemTemplate>
<asp:TextBox Width="60" runat="server" ID="NameLabel" Text='<%# XPath("@number")%>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="x1a" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="x1aTextBox" Text='<%# XPath("x1a/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t1a" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t1aTextBox" Text='<%# XPath("t1a/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t1b" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t1bTextBox" Text='<%# XPath("t1b/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t2" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t2TextBox" Text='<%# XPath("t2/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="t3" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="t3TextBox" Text='<%# XPath("t3/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="prod" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="75" runat="server" ID="prodTextBox" Text='<%# XPath("prod/dModified")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText="Notes for Prod" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:TextBox Width="125" runat="server" ID="prodNotesTextBox" Text='<%# XPath("prod/notes")%>'></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<br />
</ItemTemplate>
<InsertItemTemplate>
id:
<asp:TextBox ID="idTextBox" runat="server" Text='<%# Bind("id") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
</asp:FormView>
<asp:XmlDataSource ID="formViewDS" runat="server" DataFile="dbtasks.xml">
</asp:XmlDataSource>
<br />
</aspanel>
<br />
<asp:XmlDataSource ID="tableDataSource" runat="server" DataFile="dbTasks.xml">
</asp:XmlDataSource>
<asp:XmlDataSource ID="releaseSelectDataSource" runat="server" XPath="releases/release[@id]"
DataFile="dbTasks.xml"></asp:XmlDataSource>
<br />
<asp:Label ID="message" runat="server" BackColor="Yellow" BorderColor="White" BorderStyle="None"
Font-Bold="True" Text="unset" Visible="False"></asp:Label>
</center>
</asp:Content>
codeBehind .cs page
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Windows.Forms;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.VersionControl.Common;
using Microsoft.Win32;
public partial class DBTasks : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
pageSetup();
}
}
protected void pageSetup()
{
}
protected void ReleaseDate_SelectedIndexChanged(object sender, EventArgs e)
{
System.Web.UI.WebControls.DropDownList dList = (System.Web.UI.WebControls.DropDownList)sender;
string releaseDate = dList.Text;
//MessageBox.Show(releaseDate);
string xPath = "releases/release[@id='" + releaseDate + "']//td";
MessageBox.Show(xPath);
}
}