急问一个gridview下的checkbox奇怪的问题
我在gridview里面有一个checkbox, 我选中的时候为什么checked属性总是false
代码如下
<asp:CheckBox ID="ckAutoRenew" runat="server" />
在gridview的OnRowDataBound有如下代码
protected void gvPackage_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (gvPackage.Rows.Count > 0)
{
CheckBox ck = (CheckBox)e.Row.FindControl("ckAutoRenew");
if (ck != null)
{
OrderDataSet.SPGetAStorePlanDetailsRow aStorePlanRow = OrderDB.GetStorePlanDetailsByStorePlanID((int)gvPackage.DataKeys[e.Row.RowIndex].Values[0]);
if (aStorePlanRow.bRealTime)
{
if (!aStorePlanRow.IsvchOTRenewNull() && aStorePlanRow.vchOTRenew == "After Fulfill")
{
ck.Visible = true;
ck.Enabled = true;
}
else
{
ck.Visible = false;
ck.Enabled = false;
}
}
else
{
ck.Visible = false;
ck.Enabled = false;
}
}
}
}
最后当我点击button的时候 根据checkbox 是否选中 作如下事情
CheckBox ck=(CheckBox)gvPackage.Rows[iNumber[j]].FindControl("ckAutoRenew");
if (ck != null)
{
if (ck.Checked)
aOrderPlanRow.bCurrentMonthlyPlan = true;
else
aOrderPlanRow.bCurrentMonthlyPlan = false;
}
else
{
aOrderPlanRow.bCurrentMonthlyPlan = false;
}
control 找的也是对的 但是为什么选中后仍然ck.Checked=false? 奇怪 哪里不对呢 ?