怎样可以读取到绑定在checkbox上的数? _心急人上(在线等待) 你如果在DataGrid中的列中绑定一个Checkbox,那么所有的CheckBox对应的数是一样的!你是不是有别的意思? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的意思是一条记录一个Checkbox 以下的代码供参考 private void SetViewData() { string strSQL,strYear; DataTable dt; strYear=dblistYear.SelectedValue; string usercode=Session["user_code"].ToString(); UserClass user=new UserClass(usercode); user.GetUserInfo(usercode); if(user.strDWDM!="H01") { strSQL="select code,name from jc_jddw where code ='"+user.strDWDM+"'"; } else { strSQL="select code,name from jc_jddw where code in( select code from JC_JDDW connect by prior CODE=SJ_CODE start with SJ_CODE='J01'"; strSQL+=" MINUS select sj_code from JC_JDDW connect by prior CODE=SJ_CODE start with SJ_CODE='J01')"; } DbOper dboper=new DbOper(strSQL); dt=new DataTable(); dt.Columns.Add("if_checked"); dt.Columns.Add("dw_code"); dt.Columns.Add("dw_name"); dt.Columns.Add("chklist"); dt.Columns.Add("if_nextsj"); dt.Columns.Add("if_havesj"); if (dboper.CurrTB.Rows.Count>0) { for(int i=0;i<dboper.CurrTB.Rows.Count;i++) { DataRow newdr=dt.NewRow(); newdr["dw_code"]=dboper.CurrTB.Rows[i]["code"].ToString(); newdr["dw_name"]=dboper.CurrTB.Rows[i]["name"].ToString(); newdr["if_nextsj"]=IfNextJy(strYear,dboper.CurrTB.Rows[i]["code"].ToString()); newdr["if_havesj"]=IfHaveSj(strYear,dboper.CurrTB.Rows[i]["code"].ToString()); if(IfNextJy(strYear,dboper.CurrTB.Rows[i]["code"].ToString())=="Y") { newdr["if_checked"]="1"; } else { newdr["if_checked"]="0"; } dt.Rows.Add(newdr); } } Session["table"]=dt; DataGrid1.DataSource=dt;// this.DataGrid1.CurrentPageIndex=0; DataGrid1.DataBind(); int istartrow=0; if (this.DataGrid1.PageCount==0) { return; } if (this.DataGrid1.PageCount==1) { istartrow=0; } if (this.DataGrid1.PageCount>1) { istartrow=this.DataGrid1.PageSize*this.DataGrid1.CurrentPageIndex; } System.Web.UI.WebControls.Label lb1; System.Web.UI.WebControls.Label lb2; System.Web.UI.WebControls.Image im1; System.Web.UI.WebControls.Image im2; System.Web.UI.WebControls.CheckBox chkbox; for (int i=0;i<DataGrid1.Items.Count;i++) { im1=(System.Web.UI.WebControls.Image)DataGrid1.Items[i].Cells[2].FindControl("img1"); lb1=(System.Web.UI.WebControls.Label)DataGrid1.Items[i].Cells[2].FindControl("lb1"); im2=(System.Web.UI.WebControls.Image)DataGrid1.Items[i].Cells[3].FindControl("img2"); lb2=(System.Web.UI.WebControls.Label)DataGrid1.Items[i].Cells[3].FindControl("lb2"); chkbox=(System.Web.UI.WebControls.CheckBox)DataGrid1.Items[i].Cells[0].FindControl("chkbox"); if (dt.Rows[i+istartrow]["if_nextsj"].ToString()=="Y") { lb1.Width=0; im1.ImageUrl="../../images/Ok.bmp"; chkbox.Visible=true; chkbox.Checked=false; chkbox.Width=10; } if (dt.Rows[i+istartrow]["if_nextsj"].ToString()=="N") { lb1.Text="无"; im1.ImageUrl="../../images/blank.bmp"; im1.Width=0; chkbox.Visible=false; } if (dt.Rows[i+istartrow]["if_havesj"].ToString()=="Y") { lb2.Width=0; im2.ImageUrl="../../images/Ok.bmp"; } if (dt.Rows[i+istartrow]["if_havesj"].ToString()=="N") { lb2.Text="未形成"; im2.ImageUrl="../../images/blank.bmp"; im2.Width=0; } } } http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp 软件销售的问题 com口通讯问题 如何可以高效的将一个datatable的记录更新到另一个datatable中 关于汉字占字节的问题. 这个错误提示是什么意思 郁闷了好几天了. listview填充问题-----在线等,急!急!急!急!急!急!急!急!急!急!急! excel设置格式问题 带小数,如何只取整数位 使用用OleDb连接到Oracle数据库时候,如何插入超长的文本或者图片? "继承的公共成员声明和继承的显式接口成员声明参与重新实现的接口的接口映射过程。"这名话怎么理解?虽然给了例子,可还是不明白。 nHibernate配置问题 问一个使用TcpClient通信的问题
private void SetViewData()
{
string strSQL,strYear;
DataTable dt; strYear=dblistYear.SelectedValue;
string usercode=Session["user_code"].ToString();
UserClass user=new UserClass(usercode);
user.GetUserInfo(usercode);
if(user.strDWDM!="H01")
{
strSQL="select code,name from jc_jddw where code ='"+user.strDWDM+"'";
}
else
{
strSQL="select code,name from jc_jddw where code in( select code from JC_JDDW connect by prior CODE=SJ_CODE start with SJ_CODE='J01'";
strSQL+=" MINUS select sj_code from JC_JDDW connect by prior CODE=SJ_CODE start with SJ_CODE='J01')";
}
DbOper dboper=new DbOper(strSQL); dt=new DataTable();
dt.Columns.Add("if_checked");
dt.Columns.Add("dw_code");
dt.Columns.Add("dw_name");
dt.Columns.Add("chklist");
dt.Columns.Add("if_nextsj");
dt.Columns.Add("if_havesj");
if (dboper.CurrTB.Rows.Count>0)
{
for(int i=0;i<dboper.CurrTB.Rows.Count;i++)
{
DataRow newdr=dt.NewRow();
newdr["dw_code"]=dboper.CurrTB.Rows[i]["code"].ToString();
newdr["dw_name"]=dboper.CurrTB.Rows[i]["name"].ToString();
newdr["if_nextsj"]=IfNextJy(strYear,dboper.CurrTB.Rows[i]["code"].ToString());
newdr["if_havesj"]=IfHaveSj(strYear,dboper.CurrTB.Rows[i]["code"].ToString());
if(IfNextJy(strYear,dboper.CurrTB.Rows[i]["code"].ToString())=="Y")
{
newdr["if_checked"]="1";
}
else
{
newdr["if_checked"]="0";
}
dt.Rows.Add(newdr);
}
}
Session["table"]=dt;
DataGrid1.DataSource=dt;
// this.DataGrid1.CurrentPageIndex=0;
DataGrid1.DataBind(); int istartrow=0;
if (this.DataGrid1.PageCount==0)
{
return;
}
if (this.DataGrid1.PageCount==1)
{
istartrow=0;
}
if (this.DataGrid1.PageCount>1)
{
istartrow=this.DataGrid1.PageSize*this.DataGrid1.CurrentPageIndex;
} System.Web.UI.WebControls.Label lb1;
System.Web.UI.WebControls.Label lb2;
System.Web.UI.WebControls.Image im1;
System.Web.UI.WebControls.Image im2;
System.Web.UI.WebControls.CheckBox chkbox; for (int i=0;i<DataGrid1.Items.Count;i++)
{
im1=(System.Web.UI.WebControls.Image)DataGrid1.Items[i].Cells[2].FindControl("img1");
lb1=(System.Web.UI.WebControls.Label)DataGrid1.Items[i].Cells[2].FindControl("lb1");
im2=(System.Web.UI.WebControls.Image)DataGrid1.Items[i].Cells[3].FindControl("img2");
lb2=(System.Web.UI.WebControls.Label)DataGrid1.Items[i].Cells[3].FindControl("lb2");
chkbox=(System.Web.UI.WebControls.CheckBox)DataGrid1.Items[i].Cells[0].FindControl("chkbox"); if (dt.Rows[i+istartrow]["if_nextsj"].ToString()=="Y")
{
lb1.Width=0;
im1.ImageUrl="../../images/Ok.bmp";
chkbox.Visible=true;
chkbox.Checked=false;
chkbox.Width=10; }
if (dt.Rows[i+istartrow]["if_nextsj"].ToString()=="N")
{
lb1.Text="无";
im1.ImageUrl="../../images/blank.bmp";
im1.Width=0;
chkbox.Visible=false;
} if (dt.Rows[i+istartrow]["if_havesj"].ToString()=="Y")
{
lb2.Width=0;
im2.ImageUrl="../../images/Ok.bmp";
}
if (dt.Rows[i+istartrow]["if_havesj"].ToString()=="N")
{
lb2.Text="未形成";
im2.ImageUrl="../../images/blank.bmp";
im2.Width=0;
}
}
}