Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
I have CheckBox Inside GridView and I Dont Know how To get It in Server Side?
i Need Something like CommandArgument
Please Help me
Thanks


Faiulre Is Not An Option
Posted
Updated 31-Aug-12 7:10am
v2
Comments
_Amy 31-Aug-12 1:25am    
I like your last line of the question. :)
Seyed Ahmad Mirzaee 31-Aug-12 12:40pm    
Thanks :)

Check this article. I have explained how to get it in server side.

www.c-sharpcorner.com/UploadFile/1a81c5/non-editable-fields-in-Asp-Net-gridview/[^]
 
Share this answer
 
Comments
Seyed Ahmad Mirzaee 31-Aug-12 12:45pm    
I Want to Not Set Id For CheckBoxs
C#
protected void grvPGIS_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
           CheckBox chk= (CheckBox )e.Row.FindControl("CheckBoxID");
           
        }
    }
 
Share this answer
 
v2
Depends on where you wanna find, either in RowCommand or RowDataBound or anywhere else. In RowCommand and RowDataBound you can try casting e.Item as your DataRow. If you want to get it in other event try looping through it and use FindControl function to find your checkbox with the id.
Try this:
C#
foreach(var item in GridView1.Items)
{
     CheckBox chk=(CheckBox)item.FindControl("CheckBox1");
     //Do your job here.
}


In the gridview events try using e.Item.FindControl("CheckBox1") but make sure that e.Item is your gridview DataItem.


--Amit
 
Share this answer
 
Comments
Seyed Ahmad Mirzaee 31-Aug-12 12:47pm    
I Want Not Use Id For CheckBox
Has Way?!
Thanks

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