除非你保存CheckBox 的选中状态,否则是无法在翻页时保持CheckBox Check的状态的
解决方案 »
- 数据库超时异常怎么捕捉
- 一列数的规则如下: 1、1、2、3、5、8、13、21、34...... 求第30位数是多少,用递归算法实现。
- 使用c# Socket开发软件产品,需要在Socket程序里注意哪些技术方面的处理.
- 菜鸟问一个关于ASP.NET链接ORACLE的问题。。。
- 怎么实现c# windows程序中关闭当前Form而程序仍然运行?
- 窗体弹出的简单问题???
- SQL连接语句中的server=?
- 请教: HttpWebRequest 发送数据的方法与过程
- WPF,XAML应用程序与Silverlight
- 求助使用Expression动态拼LINQ模糊查询时字段可空问题!
- 问两个问题:1、我怎么获得程序的安装路径;2、我怎么知道计算机上是否安装了PowerPoint,请大家多多帮忙
- -------=======打印会碰到的问题=======---------
{
数据绑顶...
}
{
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;
}
}
}
在DataTable中增加一个if_checked列,BOOL型的,用来保存是否点击了,在翻页时候,根据这个值来确定DATAGRID的状态.
刚test了一下~~不行!
那就跟我这个帖子一起,和高手学东西!
to xingbing(葡萄酒)
不错的思路~~我试试~~最好有打包的源代码跑一次就更清楚了
to ym2000(tt)
哪呢?我刚看了,好像没有,挖出来给我发啊!
我忙完手头的工作来散分