Re: get cell value within gridview
- From: S_K <steve_kershaw@xxxxxxxxx>
- Date: Thu, 18 Oct 2007 09:39:38 -0700
On Oct 18, 10:18 am, "Mike" <M...@xxxxxxxxxxxxxxxxxxxx> wrote:
I have a gridview that has a button in the last cell of each row. I want to get the text from cell 1 for that row the button was clicked on.
So if my gridview looks like this:
N-12 BMW [select]
N-35 Mercedes [select]
if my user clicks row 2, I want to see Mercedes, How can I do that?
I have a buttonClick event for my select button, I'm trying to pull the values using the DataKeyName, but I keep getting 'object reference not set to an instance of an object.
here is what i'm trying
select_Click()
{
string make = grid1.SelectedDataKey.Values["CarMake"].toString();
}
any suggestions on how I can get the cell 1 text for the selected row within my Select_Click()?
Try using the GridView.SelectedIndex value to point to the selected
row.
Then use the GridView1.Rows[SelectedIndex].Cells[1].Text to get the
value inside the cell.
I hope that helps!
Steve
.
- Follow-Ups:
- Re: get cell value within gridview
- From: Mike
- Re: get cell value within gridview
- References:
- get cell value within gridview
- From: Mike
- get cell value within gridview
- Prev by Date: Re: IIS Security w/ASP.NET 2.0
- Next by Date: Re: get cell value within gridview
- Previous by thread: get cell value within gridview
- Next by thread: Re: get cell value within gridview
- Index(es):