我想在 aCheckBox
中获取 a 的值GridView
。我可以绑定GridView
使用事件RowDataBound
。但是在发生Click
事件时,Button
即使CheckBox
我检查了CheckBox
.
代码背后:
protected void GridView1_RowDatabound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList dddate = (DropDownList)e.Row.FindControl("DdlDate");
DropDownList ddYear = (DropDownList)e.Row.FindControl("DdlYear");
for (int i = System.DateTime.Now.Year; i > (System.DateTime.Now.Year) - 100; i--)
ddYear.Items.Add(Convert.ToString(i));
for (int i = 1; i < 32; i++)
dddate.Items.Add(Convert.ToString(i));
}
}
protected void btnRetrieveCheck_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("chkSel");
if (cb != null && cb.Checked)
{
DropDownList dddate = (DropDownList)row.FindControl("DdlDate"); //Bind data to the GridView control.
DropDownList ddYear = (DropDownList)row.FindControl("DdlYear");
DropDownList ddmonth = (DropDownList)row.FindControl("DdlMonth");
}
}
}