加载时在gridview中选中的复选框 [英] checkbox checked in gridview when loaded
本文介绍了加载时在gridview中选中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在加载gridview时选中gridview中的复选框.
在数据库中存储的值是true和false.
我使用该功能来检查用户和位值,但对于所有其他情况都是如此.对于特定的用户和他的行,它不能为真.
代码是:
i want to checkbox checked in gridview when gridview is loaded.
there is value true and false stored in database.
i use the function for check the user and bit value but it true for all other. it can not true for specific user and his row.
code is:
protected bool subProgram(string str)
{
int i=1;
string s11 = "Select bit_indicator,category,subctgry from document_rights where user_id='" + drop_user.SelectedItem.Value + "' and bit_indicator='" + i + "' and category='"+drop_cat.SelectedItem.Value+"' and sub_cat='"+drop_sub_cat.SelectedItem.Value+"'";
SqlDataAdapter ad2 = new SqlDataAdapter(s11, c.getcon());
DataSet ds2 = new DataSet();
ad2.Fill(ds2);
if (ds2.Tables[0].Rows.Count != 0)
{
return true;
}
else
{
return false;
}
}
我只想检查特定的用户...所以我现在该怎么办.....
所以请帮帮我..
谢谢....
i wan to check only specific user... so what can i dooo now.....
so please help me..
Thanksssss ....
推荐答案
读取数据库.设置复选框.
或者:改善您的问题,以向我们指出问题.
提问后
您的字符串连接在bit_indicator=''" + i + "'' and category
部分不起作用.您需要使用i.ToString()
将i转换为字符串.
Read the database. Set the checkbox.
Or: Improve your question to point us at the problem.
After question edit:
Your string concatenation doesn''t work at the partbit_indicator=''" + i + "'' and category
. You need to convert i to a string usingi.ToString()
.
请参阅此
http://www.ezzylearning.com/tutorial.aspx?tid=5187857 [ ^ ]
http://forums.asp.net/t/1133301.aspx/1 [ ^ ]
> http://stackoverflow.com/questions/6445178/set-checkbox- in-gridview-based-on-datatable-value [ ^ ]
http://stackoverflow.com/questions/7005258/bind- checkbox-of-gridview-with-integer-datafield-of-database [
see this
http://www.ezzylearning.com/tutorial.aspx?tid=5187857[^]
http://forums.asp.net/t/1133301.aspx/1[^]
http://stackoverflow.com/questions/6445178/set-checkbox-in-gridview-based-on-datatable-value[^]
http://stackoverflow.com/questions/7005258/bind-checkbox-of-gridview-with-integer-datafield-of-database[^]
这篇关于加载时在gridview中选中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文