Unsuccessful at loading XML in GridView

Joined
Jun 3, 2010
Messages
1
Reaction score
0
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>
<asp:panel ID="mainpanel" runat="server" BackColor="White" BorderStyle="Solid" BorderWidth="1px"
Width="95%">
<br />
<asp:panel ID="newbuildpanel" runat="server" BackColor="White" BorderStyle="Solid"
BorderWidth="1px" Width="700px">
<h1>
DB Task Tracking Tool</h1>
</asp:panel>
<br />
Release Date:&nbsp;&nbsp;<asp:DropDownList ID="ReleaseDate" Width="180px" runat="server"
ToolTip="Available Releases" AutoPostBack="True" DataSourceID="releaseSelectDataSource"
DataTextField="id" DataValueField="id" OnSelectedIndexChanged="ReleaseDate_SelectedIndexChanged">
</asp:DropDownList>
<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" />
&nbsp;<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" />
&nbsp;<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 />
</asp:panel>
<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);

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top