给你一个例子,我自己写的!string strConn=ConfigurationSettings.AppSettings["strConn"];
SqlConnection SqlConn=new SqlConnection(strConn);
SqlDataAdapter SqlCmd=new SqlDataAdapter("select ExamData.Question,ExamData.OptionAnswer,ExamData.ExamDataID from ExamData,PaperData where ExamData.ExamDataID=PaperData.ExamDataID and ExamData.Type='多选题' and PaperData.PaperID="+PaperID,SqlConn);
DataSet SqlDS=new DataSet();
SqlCmd.Fill(SqlDS,"ExamLog");
DataGridBouble.DataSource=SqlDS.Tables["ExamLog"].DefaultView;
DataGridBouble.DataBind();
for(int i=0;i<DataGridBouble.Items.Count;i++)
{
string[] strOptionAnswer;
strOptionAnswer=SqlDS.Tables["ExamLog"].Rows[i]["OptionAnswer"].ToString().Split('#');
CheckBoxList CBLDoubleOptionAnswer=(CheckBoxList)DataGridBouble.Items[i].FindControl("CBLDoubleOptionAnswer");
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[0]);
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[1]);
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[2]);
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[3]);
}
SqlConnection SqlConn=new SqlConnection(strConn);
SqlDataAdapter SqlCmd=new SqlDataAdapter("select ExamData.Question,ExamData.OptionAnswer,ExamData.ExamDataID from ExamData,PaperData where ExamData.ExamDataID=PaperData.ExamDataID and ExamData.Type='多选题' and PaperData.PaperID="+PaperID,SqlConn);
DataSet SqlDS=new DataSet();
SqlCmd.Fill(SqlDS,"ExamLog");
DataGridBouble.DataSource=SqlDS.Tables["ExamLog"].DefaultView;
DataGridBouble.DataBind();
for(int i=0;i<DataGridBouble.Items.Count;i++)
{
string[] strOptionAnswer;
strOptionAnswer=SqlDS.Tables["ExamLog"].Rows[i]["OptionAnswer"].ToString().Split('#');
CheckBoxList CBLDoubleOptionAnswer=(CheckBoxList)DataGridBouble.Items[i].FindControl("CBLDoubleOptionAnswer");
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[0]);
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[1]);
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[2]);
CBLDoubleOptionAnswer.Items.Add(strOptionAnswer[3]);
}
我要的是选Checkboxlist项后的事件代码及动态生成属性代码
我的问题是checkboxlist有多个item,当点击其中一个时怎么抓出我点击的是哪个
----------------》用checkboxlist.SelectedItem就知道是哪项