Click here to Skip to main content
14,828,290 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i m new to asp.net n i m working with datagrid and i m stucked with something.

i have a datagrid with paging allowed and pagesize is set to 5..n i have 2 pages in datagrid and it has a checkbox.when the header checkbox is clicked all the checkbox in the first page is selected but what i want is...even d sec page checkbox have to be selected when the header checkbox is clicked n the data to datagrid is from a list .pls help me wit it..i dont want to use javascript
Posted

1 solution

You can do it using RowDataBound event of the GridView, find the checkboxes in each row and set the selected property as true.

check the following links
http://forums.asp.net/t/1377065.aspx[^]
http://forums.asp.net/p/1370809/2866640.aspx#2866838[^]
   
Comments
Member 8459400 5-Dec-11 0:22am
   
ya..i tried doing tat..using onitemdatabound..but when i write a condition...when the header checkbox is selected then i get an error..let me knw if i m doing it wrong..this is the code i m using for onitemdatabound


CheckBox cl = d1.FindControl("chkall") as CheckBox;//chkall is d id of the header checkbox
foreach (DataGridItem di in d1.Items)
{
CheckBox ck = di.FindControl("chkitem") as CheckBox;//chkitem is the id of the checkbox
if(cl.Checked==true)
ck.Checked = true;

}
Member 8459400 5-Dec-11 0:24am
   
CheckBox cl = d1.FindControl("chkall") as CheckBox;
foreach (DataGridItem di in d1.Items)
{
CheckBox ck = di.FindControl("chkitem") as CheckBox;
if(cl.Checked==true)//error is over here
ck.Checked = true;

}

thanks for ur replyin

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900