Item Template

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 8
Reputation: amith003 is an unknown quantity at this point 
Solved Threads: 0
amith003 amith003 is offline Offline
Newbie Poster

Item Template

 
0
  #1
Jan 3rd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: Item Template

 
0
  #2
Jan 4th, 2008
hi,
use item created or item databound event to write the code u need for checkbox
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 39
Reputation: btech_Saurabh is an unknown quantity at this point 
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

Re: Item Template

 
0
  #3
Jan 4th, 2008
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...."
}
}
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 8
Reputation: amith003 is an unknown quantity at this point 
Solved Threads: 0
amith003 amith003 is offline Offline
Newbie Poster

Re: Item Template

 
0
  #4
Jan 4th, 2008
Originally Posted by btech_Saurabh View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 39
Reputation: btech_Saurabh is an unknown quantity at this point 
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

Re: Item Template

 
0
  #5
Jan 7th, 2008
int32 i=e.RowIndex(); // worked in RowDataBound event
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Item Template

 
0
  #6
Jan 15th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC