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? 5 13078
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******** *************** ***********@mic rosoft.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?
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******** *************** ***********@mic rosoft.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?
not?
Search for the row with the same id and you'll know the row, right?
(row.FindContro l("imagebutton" ) for the imagebutton or search for the cell
where the imagebutton is in.
"NH" <NH@discussions .microsoft.com> wrote in message
news:92******** *************** ***********@mic rosoft.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******** *************** ***********@mic rosoft.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?
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.FindContro l("imagebutton" ) for the imagebutton or search for the cell where the imagebutton is in.
"NH" <NH@discussions .microsoft.com> wrote in message news:92******** *************** ***********@mic rosoft.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******** *************** ***********@mic rosoft.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?
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******** *************** ***********@mic rosoft.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.FindContro l("imagebutton" ) for the imagebutton or search for the cell where the imagebutton is in.
"NH" <NH@discussions .microsoft.com> wrote in message news:92******** *************** ***********@mic rosoft.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******** *************** ***********@mic rosoft.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? >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the "DataTextField" as the
productID of the product that I want to add. This works but the button
displays the productID as the text instead of "Add to Cart".
What is the best way to get this to work?
|
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. Everyone
wants to do a java confirmation box when a user clicks the delete button.
Fair enough, basic user design rules state that you should always confirm a
delete action. There is also a consensus that the best way to do this is a
template...
|
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 in the database when the
user press a "View All" button.
In this case, I need to change the select comand and clear the
parameters. And I did this in the button_click() event. the GridView
can display desired results when I press the "View All"...
|
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 a datasource that also contains the
update/delete Sql statements? The resaon I ask is that I've done just about
all I can do and can't update the grid. In the RowUpdating event I'm getting
no values in the newvalues or oldvalues vars. I do bind a...
|
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 OleDbParameterCollection" whenI try to write a new record.
Delete and Modify work fine its just the add record function causes the
error.
| |
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 need to
be updated based on the data in the gridview.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:slightsInventoryConnectionString %>"
SelectCommand="SELECT * FROM "
UpdateCommand="upd_Inventory"...
|
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 it doesn't seem to work at
all. Below is my ASP.NET page, and further below, my VB.NET method that
I am trying to call:
<div id="admin-faq" class="page">
<h2>Site FAQs (Frequently Asked Questions)</h2>
|
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 fields to be included in the
table, which is to be bound to the gridview.
The web form looks like so (Don't worry about the stupidity of this
web form for now.):
|
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 problems?
Thanks.
Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging
without postbacks (or at least not documented how to fix it). Once the
GridView is displayed, clicking on any of the paging tools causes the
|
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 columns. These are all for data
entry and although I am populating the dropdown list boxes with an
objectdatasource so the user can provide a selection, I am not binding the
gridview to anything. The command buttons again are for the user to be...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |