473,320 Members | 2,000 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

gridview row command

NH
How do I find out the row index selected in the gridveiw row command method?

I have an imageButton in a gridview cell and its corresponding code in the
row command method needs to know the row index in question in order to set
the background of the cell to a different color. But the selectedIndex value
doesnt return a value as expected.

Is there something I am missing?
Apr 18 '06 #1
5 13061
You can use the SelectedDataKey property to retrieve the DataKey object for
the currently selected row. You can also use the SelectedValue property to
retrieve the data key value for the currently selected row directly.

"NH" <NH@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
How do I find out the row index selected in the gridveiw row command
method?

I have an imageButton in a gridview cell and its corresponding code in the
row command method needs to know the row index in question in order to set
the background of the cell to a different color. But the selectedIndex
value
doesnt return a value as expected.

Is there something I am missing?

Apr 18 '06 #2
NH
thanks, but that wont let me know which row index was selected..?

"Pipo" wrote:
You can use the SelectedDataKey property to retrieve the DataKey object for
the currently selected row. You can also use the SelectedValue property to
retrieve the data key value for the currently selected row directly.

"NH" <NH@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
How do I find out the row index selected in the gridveiw row command
method?

I have an imageButton in a gridview cell and its corresponding code in the
row command method needs to know the row index in question in order to set
the background of the cell to a different color. But the selectedIndex
value
doesnt return a value as expected.

Is there something I am missing?


Apr 18 '06 #3
not?
Search for the row with the same id and you'll know the row, right?
(row.FindControl("imagebutton") for the imagebutton or search for the cell
where the imagebutton is in.
"NH" <NH@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
thanks, but that wont let me know which row index was selected..?

"Pipo" wrote:
You can use the SelectedDataKey property to retrieve the DataKey object
for
the currently selected row. You can also use the SelectedValue property
to
retrieve the data key value for the currently selected row directly.

"NH" <NH@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
> How do I find out the row index selected in the gridveiw row command
> method?
>
> I have an imageButton in a gridview cell and its corresponding code in
> the
> row command method needs to know the row index in question in order to
> set
> the background of the cell to a different color. But the selectedIndex
> value
> doesnt return a value as expected.
>
> Is there something I am missing?


Apr 18 '06 #4
NH
The SelectedDataKey only holds the datakey of the datasource, this is not the
same as the row index, the datakey could be a customerID which is not going
to be the same as the row index. Or am I mistaken?

"Pipo" wrote:
not?
Search for the row with the same id and you'll know the row, right?
(row.FindControl("imagebutton") for the imagebutton or search for the cell
where the imagebutton is in.
"NH" <NH@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
thanks, but that wont let me know which row index was selected..?

"Pipo" wrote:
You can use the SelectedDataKey property to retrieve the DataKey object
for
the currently selected row. You can also use the SelectedValue property
to
retrieve the data key value for the currently selected row directly.

"NH" <NH@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
> How do I find out the row index selected in the gridveiw row command
> method?
>
> I have an imageButton in a gridview cell and its corresponding code in
> the
> row command method needs to know the row index in question in order to
> set
> the background of the cell to a different color. But the selectedIndex
> value
> doesnt return a value as expected.
>
> Is there something I am missing?


Apr 18 '06 #5
No you are right, sorry
What I always do is that I have a column (visible = false) with the unique
record ID.
With that I can find the row which was selected.
I was in the wrong assumpsion you did that also.

"NH" <NH@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
The SelectedDataKey only holds the datakey of the datasource, this is not
the
same as the row index, the datakey could be a customerID which is not
going
to be the same as the row index. Or am I mistaken?

"Pipo" wrote:
not?
Search for the row with the same id and you'll know the row, right?
(row.FindControl("imagebutton") for the imagebutton or search for the
cell
where the imagebutton is in.
"NH" <NH@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
> thanks, but that wont let me know which row index was selected..?
>
> "Pipo" wrote:
>
>> You can use the SelectedDataKey property to retrieve the DataKey
>> object
>> for
>> the currently selected row. You can also use the SelectedValue
>> property
>> to
>> retrieve the data key value for the currently selected row directly.
>>
>>
>>
>> "NH" <NH@discussions.microsoft.com> wrote in message
>> news:FD**********************************@microsof t.com...
>> > How do I find out the row index selected in the gridveiw row command
>> > method?
>> >
>> > I have an imageButton in a gridview cell and its corresponding code
>> > in
>> > the
>> > row command method needs to know the row index in question in order
>> > to
>> > set
>> > the background of the cell to a different color. But the
>> > selectedIndex
>> > value
>> > doesnt return a value as expected.
>> >
>> > Is there something I am missing?
>>
>>
>>


Apr 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: | last post by:
Hello, I am trying to get add a product to a cart from a gridview control when a button in the gridview is clicked. I have a book on how to do this in asp.net 2.0 but it is done by specifying...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
5
by: yefei | last post by:
In my web design, I display records from a SQL DataBase according to some filters the GridView is defined with select commands and selest parameters however, I also want to display all records...
5
by: Michael | last post by:
Hi Everyone, I've been having a problem with the Gridview control. I have posted a few messages relating to the issues, but I have a general question. Does the Dataview control have to be bound to...
1
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
0
by: troyblakely | last post by:
I have a gridview which is pulling data from a SqlDataSource, the select command queries a view and the update command is a stored procedure. I'm using a stored procedure because several tables...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
4
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview with several template columns and a few command button columns, column 1 and 2 are dropdown boxes, column 3 is a checkbox and column 4 is a text box, followed by command button...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.