We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Checkbox in Datagrid of ASP.NET

Thread ID:

Created:

Updated:

Platform:

Replies:

41144 Feb 23,2006 02:35 AM Mar 3,2006 06:40 AM ASP.NET Web Forms (Classic) 4
loading
Tags: FAQ
Megha Bansal
Asked On February 23, 2006 02:35 AM

Hi I''m using the checkbox as a template column in datagrid. I was able to add the checkbox but I''m not able to retreive which checkbox have been clicked. I have gon through ur articles 25.71,25.76,25.77 but still not able to retrieve the checked value! Plz help by clearly stating how to use them! thanks and regards! Megha

Administrator [Syncfusion]
Replied On February 23, 2006 08:08 AM

Hi Megha, You can easily get the row of which row is clicked , There are a lot ways to do this. Eg. In the ButtonClickedevent in server try one of the following ( applies for all controls events not only for button you can use check box , I already have the sample for button click) [C#] Button btn = (Button)sender as Button; DataGridItem myItem =(DataGridItem) btn.NamingContainer; //This will return the selected rows index value starts from 0 myItem.ItemIndex; //also you can use to get some of the key field of that row with the following code //Here i assume first column will have a unique value so given Cells[0] and in which you can use for your changes in server side. string rowId; rowId = myItem.Cells[0].Text; I guess the above codings should give you some idea Regards, A.Sivakumar

Megha Bansal
Replied On February 23, 2006 11:46 PM

Hi SivaKumar. Thanks for ur reply! But I''m sorry it didnt work. It gave me error on line myitem.itemindex; saying only assignment,call,increment,decrement, and new obeject expressions can be used as a statement. plz check the error code and reply me back. Thanks and Regards! Megha >Hi Megha, > >You can easily get the row of which row is clicked , There are a lot ways to do this. > >Eg. >In the ButtonClickedevent in server try one of the following ( applies for all controls events not only for button you can use check box , I already have the sample for button click) > >[C#] > Button btn = (Button)sender as Button; > DataGridItem myItem =(DataGridItem) btn.NamingContainer; > >//This will return the selected rows index value starts from 0 > >myItem.ItemIndex; > >//also you can use to get some of the key field of that row with the following code > >//Here i assume first column will have a unique value so given Cells[0] and in which you can use for your changes in server side. > > string rowId; > rowId = myItem.Cells[0].Text; > > >I guess the above codings should give you some idea > >Regards, >A.Sivakumar >

Administrator [Syncfusion]
Replied On February 24, 2006 03:55 AM

> >Hi SivaKumar. > Hi Megha, As i said before , " this will return the value start from 0" . you can probably use int something=myItem.ItemIndex; and this something will be your rowindex Let me know if this helps Best Regards, A.Sivakumar //This will return the selected rows index value starts from 0 >> >>myItem.ItemIndex; >> >>//also you can use to get some of the key field of that row with the following code >> >>//Here i assume first column will have a unique value so given Cells[0] and in which you can use for your changes in server side. >> >> string rowId; >> rowId = myItem.Cells[0].Text; >> >> >>I guess the above codings should give you some idea >> >>Regards, >>A.Sivakumar >>

tyt
Replied On March 3, 2006 06:40 AM

>Hi > >I''m using the checkbox as a template column in datagrid. I was able to add the checkbox but I''m not able to retreive which checkbox have been clicked. >I have gon through ur articles 25.71,25.76,25.77 but still not able to retrieve the checked value! > >Plz help by clearly stating how to use them! > >thanks and regards! >Megha

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;