Unsuccessful at loading XML in GridView

Discussion in '.NET' started by dcoulic, Jun 3, 2010.

  1. dcoulic

    dcoulic

    Joined:
    Jun 3, 2010
    Messages:
    1
    Location:
    Washington
    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);

    }
    }
     
    dcoulic, Jun 3, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2FnYXI=?=

    i was unsuccessful in sending email using asp

    =?Utf-8?B?c2FnYXI=?=, Feb 21, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    872
    w66327
    Feb 22, 2005
  2. Stan Goodman
    Replies:
    14
    Views:
    630
    Stan Goodman
    Aug 27, 2005
  3. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    18,046
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  4. August Karlstrom

    Making a SELECT unsuccessful

    August Karlstrom, Nov 24, 2008, in forum: HTML
    Replies:
    10
    Views:
    794
    Jonathan N. Little
    Nov 26, 2008
  5. tchangmian
    Replies:
    4
    Views:
    151
    Mark Schupp
    Dec 13, 2004
Loading...

Share This Page