Advertise with us
Control Panel
Forum
Hosting Help
ASP.NET 4.5 & SQL 2012 Hosting
Resources
Notice
Login
Members
Shared Hosting
|
Upgrade
|
Advertise
|
Tutorials
|
Home
»
Questions & Answers
»
make checkbox true in gridview when binding data
make checkbox true in gridview when binding data
25 Apr, 12
Author:
Mitesh S Machhi
Fairmate Chemical Pvt.Ltd
i am using gridview and there is a column of checkbox so i want to checkbox make true for value that come from database and match with some row data. so what can i do ?
string s = select document_id,user_id from document_rights where user_id=' +drop_user.SelectedItem.Value + ' and category=' +drop_cat.SelectedItem.Value+ ' and sub_cat=' + drop_sub_cat.SelectedItem.Value + ';
SqlDataAdapter ad = new SqlDataAdapter(s, c.getcon());
DataSet ds = new DataSet();
ad.Fill(ds);
if (ds.Tables[0].Rows.Count != 0)
{
xxx = ds.Tables[0].Rows[0][0].ToString();
string[] split = xxx.Split(',');
intArray1 = new int[split.Length];
for (int i = 0; i < split.Length; i++)
{
intArray1[i] = System.Convert.ToInt32(split[i]);
}
string xxxx = select title,id from document where id in(;
for (int k = 0; k < intArray1.Length; k++)
{
xxxx += intArray1[k] + ,;
}
xxxx = xxxx.Substring(0, xxxx.Length - 1) + ) and category=' + drop_cat.SelectedItem.Value + ' and subctgry=' + drop_sub_cat.SelectedItem.Value + ';
SqlDataAdapter ad1 = new SqlDataAdapter(xxxx, c.getcon());
DataSet ds1 = new DataSet();
ad1.Fill(ds1);
if (ds1.Tables[0].Rows.Count != 0)
{
foreach (GridViewRow di in GridView1.Rows)
{
CheckBox chkBx = (CheckBox)di.FindControl(CheckBox1);
}
}
GridView1.DataSource = c.getdata(select id,title from document where category=' + drop_cat.SelectedItem.Text + ' and subctgry=' + drop_sub_cat.SelectedItem.Text + ');
GridView1.DataBind();
}
Answers .............
You must
login
to post answer for this question.
Total
members
:
250970
Average new registrations per day (in last 7 days):
8
New Registration:
Open
Register Now
Talk to Webmaster
Tony John
Facebook
Google+
Twitter
Advertise
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies Pvt Ltd.
All Rights Reserved.