Hi,
I have been trying to create a set of web pages that reads an xml file
into a datagrid this I can do. Here is a sample of the code.
DataSet myDataSet = new DataSet();
myDataSet.ReadXml("Addrbook.xml");
dgBooks.DataSource = myDataSet;
dgBooks.DataBind();
<asp:datagrid id="dgBooks" runat="server"
AutoGenerateColumns="False"
AllowSorting="true" OnSortCommand="dgBooks_Sort"
AllowPaging="True" PageSize="25" PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="right" OnPageIndexChanged="dgBooks_NextPage">
<Columns>
<asp:HyperLinkColumn HeaderText="Name"
DataNavigateUrlField="fullName"
DataNavigateUrlFormatString="Details.aspx?id={0}" DataTextField="fullName"
Target="_self" />
<asp:BoundColumn HeaderText="E-mail Address" DataField="email" />
<asp:BoundColumn HeaderText="Comment" DataField="comment" />
</Columns>
</asp:datagrid>
I have also been able to get the paging of the data to work. Code as
follows.
protected void dgBooks_NextPage(Object sender,
DataGridPageChangedEventArgs e)
{
dgBooks.CurrentPageIndex = e.NewPageIndex;
dgBooks.DataBind();
}
I also want to be able to sort the data by different columns and I found a
sample for an sql datasource but it did not work on my xml data. Can
somebody show me a sample that works with the xml data.
Also I found a sample that shows how to make a link from the datagrid to a
new page. I got this to work as shown here.
<asp:HyperLinkColumn HeaderText="Name"
DataNavigateUrlField="fullName"
DataNavigateUrlFormatString="Details.aspx?id={0}" DataTextField="fullName"
Target="_self" />
I need to know how to display the one selected record in detail on the new
page. This was not shown in the example that I found. I would also like to
be able to edit the fields shown on the details page. A working sample would
be nice.
Thanks
Kenneth