G
Guest
Hi.
I have a checkbox column in my datagrid like this:
<Columns>
<asp:TemplateColumn HeaderText=" ">
<ItemTemplate>
<asp:CheckBox ID='Selection'
runat="server"></asp:CheckBox>
<asp:Label ID="SelectID" Visible="False" Text='<%#
DataBinder.Eval(Container.DataItem, "CustomerID") + "_" +
DataBinder.Eval(Container.DataItem, "OrderID") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>
When I try to get the state of checked checkboxes, it's telling me that it's
not checked. I tried EnableViewState=true, but the result is the same.
Here is my code behind:
private void btnInclude_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.CheckBox oCheckBox;
string sID;
foreach (DataGridItem oItem in DataGrid1.Items)
{
oCheckBox = (System.Web.UI.WebControls.CheckBox)
oItem.FindControl("Selection");
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;
if (oCheckBox.Checked)
{
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;
int nTemp = 0;
}
}
However, the value of sID comes out correctly. Your input is appreciated.
I have a checkbox column in my datagrid like this:
<Columns>
<asp:TemplateColumn HeaderText=" ">
<ItemTemplate>
<asp:CheckBox ID='Selection'
runat="server"></asp:CheckBox>
<asp:Label ID="SelectID" Visible="False" Text='<%#
DataBinder.Eval(Container.DataItem, "CustomerID") + "_" +
DataBinder.Eval(Container.DataItem, "OrderID") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>
When I try to get the state of checked checkboxes, it's telling me that it's
not checked. I tried EnableViewState=true, but the result is the same.
Here is my code behind:
private void btnInclude_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.CheckBox oCheckBox;
string sID;
foreach (DataGridItem oItem in DataGrid1.Items)
{
oCheckBox = (System.Web.UI.WebControls.CheckBox)
oItem.FindControl("Selection");
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;
if (oCheckBox.Checked)
{
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;
int nTemp = 0;
}
}
However, the value of sID comes out correctly. Your input is appreciated.