For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > April 2007 > How to retrieve a column from a selected GridView row.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to retrieve a column from a selected GridView row.
Steve Kershaw

2007-04-20, 7:06 pm

Hi,

I have a GridView in which I have selected a row. I now want to use
the 1st column value of that selected row in another GridView as an
input to select the particular row in the second GridView. I know that
"GridView1.SelectedRow.Cells[0]" dosen't work along with some other
things I have tried.

Can anybody help me with this?!

Thanks in advance.
Steve

Randy Smith

2007-04-28, 7:06 pm

Hi,
I've got this code, and seems to work quite well:

foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chk1 = (CheckBox) row.FindControl("chk1");
if (chk1.Checked == true)
{
//code goes here
}
}

The point of this code is that it is necessary to "find" the control, and
place the contents into a newly created variable. In the case above, the
variable is "chk1", but it can be anything. Although it might be confusing,
the name of the control on the aspx form is also "chk1".

HTH, Randy




"Steve Kershaw" <steve_kershaw@yahoo.com> wrote in message
news:1177087456.984058.299300@e65g2000hsc.googlegroups.com...
> Hi,
>
> I have a GridView in which I have selected a row. I now want to use
> the 1st column value of that selected row in another GridView as an
> input to select the particular row in the second GridView. I know that
> "GridView1.SelectedRow.Cells[0]" dosen't work along with some other
> things I have tried.
>
> Can anybody help me with this?!
>
> Thanks in advance.
> Steve
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com