954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Item Template

Hi all,
I have created a DataGrid and i have included a template field of checkboxes(i.e' a column is created consisring of checkboxes) now i want to know how to get the data from the row in the datagrid where checkbox is selected and assign that data to any variable?

Thanks in Advance
Amith A

amith003
Newbie Poster
8 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

hi,
use item created or item databound event to write the code u need for checkbox

greeny_1984
Posting Whiz
372 posts since Apr 2007
Reputation Points: 25
Solved Threads: 29
 

first u have to create an object of Checkbox
then u have to find that checkbox in ur Datagrid using loop like
checkbox chk;
for(int i=0;i<=datagrid.rows.count-1;i++)
{
chk=(CheckBox)Datagrid1.Items[i].findcontrol("CheckboxName");
if(chk.Checked)
{
"Pick the value of that row...."
}
}

btech_Saurabh
Light Poster
39 posts since Jan 2008
Reputation Points: 10
Solved Threads: 2
 
first u have to create an object of Checkbox then u have to find that checkbox in ur Datagrid using loop like checkbox chk; for(int i=0;i<=datagrid.rows.count-1;i++) { chk=(CheckBox)Datagrid1.Items[i].findcontrol("CheckboxName"); if(chk.Checked) { "Pick the value of that row...." } }


-----------------------------------------------------------------------------

Thanks for your reply, this i hav done can u tell me how to pick the value of the row and put it into some variable?

amith003
Newbie Poster
8 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

int32 i=e.RowIndex(); // worked in RowDataBound event

btech_Saurabh
Light Poster
39 posts since Jan 2008
Reputation Points: 10
Solved Threads: 2
 

That or if you wish to set your own value, you can set an attribute on your checkbox with any value you wish. Then when a checkbox is clicked, you pull it's value. Might work better than rowIndex depending on what you're doing on your application.

SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You