D
Douglas Gage
How to get contents out of datagrid? I have fixed the problem before but now when i debug I could not see any thing in the text box
public void updateQuestion(object sender,System.EventArgs e)
{
ArrayList myAnsList = new ArrayList();
foreach(DataGridItem item in grid.Items)
{
TextBox ans = (TextBox)item.FindControl("answerbox");
myAnsList.Add(ans.Text.ToString()); ///ans.Text -> there is nothing here?
}
//update
loadProDataTalbe(myAnsList);
}
<asp:datagrid id="grid" runat="server" Width="608px" OnItemCreated="ItemCreated" AutoGenerateColumns="False"
CellSpacing="1" GridLines="None" CellPadding="3" BackColor="White" BorderWidth="2px" BorderStyle="Ridge" BorderColor="White" ShowFooter="True">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle>
<ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle>
<FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
<PagerStyle HorizontalAlign="Right" ForeColor="Black" BackColor="#C6C3C6"></PagerStyle>
<Columns>
<asp:BoundColumn DataField="Q_Question" HeaderText="Questions"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:TextBox Runat="server" ID="answerbox"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
public void updateQuestion(object sender,System.EventArgs e)
{
ArrayList myAnsList = new ArrayList();
foreach(DataGridItem item in grid.Items)
{
TextBox ans = (TextBox)item.FindControl("answerbox");
myAnsList.Add(ans.Text.ToString()); ///ans.Text -> there is nothing here?
}
//update
loadProDataTalbe(myAnsList);
}
<asp:datagrid id="grid" runat="server" Width="608px" OnItemCreated="ItemCreated" AutoGenerateColumns="False"
CellSpacing="1" GridLines="None" CellPadding="3" BackColor="White" BorderWidth="2px" BorderStyle="Ridge" BorderColor="White" ShowFooter="True">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle>
<ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle>
<FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
<PagerStyle HorizontalAlign="Right" ForeColor="Black" BackColor="#C6C3C6"></PagerStyle>
<Columns>
<asp:BoundColumn DataField="Q_Question" HeaderText="Questions"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Answer">
<ItemTemplate>
<asp:TextBox Runat="server" ID="answerbox"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>