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
»
checkbox checked in gridview
checkbox checked in gridview
26 Apr, 12
Author:
Mitesh S Machhi
Fairmate Chemical Pvt.Ltd
I AM USING GRIDVIEW. THERE IS 3 COLUMN.E.G. FIRST IS CHECKBOX THEN NAME THEN ADDRESS.
CHECKBOX CHECKED FROM THE VALUE OF ANOTHER TABLE AND OTHER TWO FIELDS COME FROM FIRST TABLE. I ALSO WANT TO DISPLAY ALL RECORDS FROM THE FIRST TABLE.
I WANT THAT .........
IF I SELECT THE NAME FROM DROPDOWN LIST AND IF ITS VALUE TRUE FROM OTHER TABLE IS AUTOMATICLY CHECKED. AND ALSO I WANT DISPLAY OTHER DATA IN GRID FROM FIRST TABLE AND ITS VALUE FOR CHECKBOX FALSE IF IT IS NOT MATCH...
SOOO, IN SORT I WANT TO CHECKBOX CHECKED TRUE IF MATCH AND FALSE IF IT NOT MATCH AND DISPLAY ALL RECORDS FROM FIRST TABLE..
CODE WHICH I HAVE USE :
protected void Button1_Click1(object sender, EventArgs e)
{
String xxx = ;
Button2.Visible = true;
Panel1.Visible = true;
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 id,title 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 + ' ;
string xxxx1 = SELECT DISTINCT document.user_id, document.id, document_rights.bit_indicator, document.title FROM document CROSS JOIN document_rights where document.category=' + drop_cat.SelectedItem.Value + ' and document.subctgry=' + drop_sub_cat.SelectedItem.Value + ';
SqlDataAdapter ad1 = new SqlDataAdapter(xxxx1, 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);
//if (chkBx.Checked==false)
//{
//int i=1;
//string s11=Select bit_indicator from document_rights where user_id='+drop_user.SelectedItem.Value+' and bit_indicator='+i+';
//SqlDataAdapter ad2 = new SqlDataAdapter(s11, c.getcon());
//DataSet ds2 = new DataSet();
//ad2.Fill(ds2);
//if (ds2.Tables[0].Rows.Count != 0)
//{
// chkBx.Checked = true;
//}
//}
}
}
//ds.Merge(ds1, false, MissingSchemaAction.Add);
GridView1.DataSource = ds1;
GridView1.DataBind();
}
//GridView1.DataSource =c.getdata(SELECT DISTINCT document.user_id, document.id, document_rights.bit_indicator, document.title FROM document CROSS JOIN document_rights where document.category='+drop_cat.SelectedItem.Value+' and document.subctgry='+drop_sub_cat.SelectedItem.Value+');
//GridView1.DataBind();
//SqlDataAdapter ad = new SqlDataAdapter(SELECT document.user_id, document.id, document_rights.bit_indicator FROM document INNER JOIN document_rights ON document.user_id = document_rights.user_id, c.getcon());
//DataSet ds = new DataSet();
//ad.Fill(ds);
////SqlDataAdapter ad1 = new SqlDataAdapter(select bit_indicator from document_rights where category=' + drop_cat.SelectedItem.Text + ' and sub_cat=' + drop_sub_cat.SelectedItem.Text + ', c.getcon());
////DataSet ds1 = new DataSet();
////ad1.Fill(ds1);
////ds.Merge(ds1);
//GridView1.DataSource = ds;
//GridView1.DataBind();
}
please help me...
Thankss in advance...
Mitesh
Answers .............
You must
login
to post answer for this question.
Total
members
:
250684
Average new registrations per day (in last 7 days):
7
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.