Hello
I currently have a Datagridview which takes data from an XML file.
I want to display the array of numbers.
Here is the code for my GridView:
<asp:GridView ID="rd" runat="Server" OnRowEditing="Editdata" OnPageIndexChanging="pageddata"
OnRowDeleting="Deletedata" OnRowUpdating="Updatedata" OnRowCancelingEdit="Canceldata"
AllowPaging="True" AutoGenerateColumns="False" PageSize="30" CellPadding="4"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:TemplateField HeaderText="DataField">
<ItemTemplate>
<asp:Label ID="lblDataField" runat="server" Text='<%#Eval("DataField") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDataField" runat="server" ReadOnly="true" Visible="true" Text='<%#Eval("DataField") %>'></asp:TextBox>
<%-- Visible=false to hide textbox, ReadOnly=true to make textbox ReadOnly --%>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header">
<ItemTemplate>
<asp:Label ID="lblHeader" runat="server" Text='<%#Eval("Header") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtHeader" runat="server" Text='<%#Eval("Header") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UseDefaults">
<ItemTemplate>
<asp:Label ID="lblUseDefaults" runat="server" Text='<%#Eval("UseDefaults") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUseDefaults" runat="server" Text='<%#Eval("UseDefaults") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ButtonType="Button" />
<asp:CommandField ShowDeleteButton="True" ButtonType="Button" />
</Columns>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Now what I want to do know is how can I obtain an array of the DataField column. For example it has A01, A02, A03 I need to check how many entries exist and them put them into a textbox for example.
Is this possible?
I've currently used this to take the last 'DataFeild' value from the gridview:
void binddata()
{
DataSet rdawTest = new DataSet();
rdawTest.ReadXml(Server.MapPath(@"xml\" + Request["Gradebook"] + ".xml"));
foreach (DataColumn da in rdawTest.Tables[0].Columns)
{
da.ColumnMapping = MappingType.Attribute;
}
rd.DataSource = rdawTest;
rd.DataBind();
DataSet ds = rd.DataSource as DataSet;
DataRow dr = ds.Tables[0].NewRow();
int index = rd.Rows.Count - 1;
GridViewRow gRow = rd.Rows[index];
String str = ((Label)(gRow.Cells[0].Controls[1])).Text;
txtArray.Text = str;
}
Thank you.