473,809 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get value from an image button in a row in GridView

Hi.

I have a gridview in which each row has an image button attached. I
have each button in each row set up to be associated with a DB field.
When I hover above the button it shows me the correct value of the DB
field in a tooltip, so there is no problem there. But ...how do I
access that value? When the user clicks that button I will redirect
him to a new page and I need to use the value as an ID in a
querystring, but cannot figure out how to retrieve it. Everything
else (except optaining the value) works fine. I searched online but
cannot find the answer.

Any help?

Thanks,
Steve
Nov 26 '07 #1
3 4523
Using PostbackUrl property:

<asp:ImageButto n runat="server" ID="ib" ToolTip='<%# Eval("ID") %>'
PostBackUrl='<% # "EditPage.aspx? ID=" + Eval("ID") %>' />

Hope this helps?

"gl****@gmail.c om" wrote:
Hi.

I have a gridview in which each row has an image button attached. I
have each button in each row set up to be associated with a DB field.
When I hover above the button it shows me the correct value of the DB
field in a tooltip, so there is no problem there. But ...how do I
access that value? When the user clicks that button I will redirect
him to a new page and I need to use the value as an ID in a
querystring, but cannot figure out how to retrieve it. Everything
else (except optaining the value) works fine. I searched online but
cannot find the answer.

Any help?

Thanks,
Steve
Nov 26 '07 #2
On Nov 26, 2:42 am, Siva M <shiva...@onlin e.excite.comwro te:
Using PostbackUrl property:

<asp:ImageButto n runat="server" ID="ib" ToolTip='<%# Eval("ID") %>'
PostBackUrl='<% # "EditPage.aspx? ID=" + Eval("ID") %>' />

Hope this helps?

"glb...@gmail.c om" wrote:
Hi.
I have a gridview in which each row has an image button attached. I
have each button in each row set up to be associated with a DB field.
When I hover above the button it shows me the correct value of the DB
field in a tooltip, so there is no problem there. But ...how do I
access that value? When the user clicks that button I will redirect
him to a new page and I need to use the value as an ID in a
querystring, but cannot figure out how to retrieve it. Everything
else (except optaining the value) works fine. I searched online but
cannot find the answer.
Any help?
Thanks,
Steve- Hide quoted text -

- Show quoted text -

Siva,

That would work on an image button, but I need it to work on a
Gridview's button control: <ASP:BUTTONFIEL D BUTTONTYPE="Ima ge"

Any ideas on that?

Thanks,
Steve
Nov 26 '07 #3

<gl****@gmail.c omwrote in message
news:e1******** *************** ***********@g30 g2000hsb.google groups.com...
On Nov 26, 2:42 am, Siva M <shiva...@onlin e.excite.comwro te:
>Using PostbackUrl property:

<asp:ImageButt on runat="server" ID="ib" ToolTip='<%# Eval("ID") %>'
PostBackUrl='< %# "EditPage.aspx? ID=" + Eval("ID") %>' />

Hope this helps?

"glb...@gmail. com" wrote:
Hi.
I have a gridview in which each row has an image button attached. I
have each button in each row set up to be associated with a DB field.
When I hover above the button it shows me the correct value of the DB
field in a tooltip, so there is no problem there. But ...how do I
access that value? When the user clicks that button I will redirect
him to a new page and I need to use the value as an ID in a
querystring, but cannot figure out how to retrieve it. Everything
else (except optaining the value) works fine. I searched online but
cannot find the answer.
Any help?
Thanks,
Steve- Hide quoted text -

- Show quoted text -


Siva,

That would work on an image button, but I need it to work on a
Gridview's button control: <ASP:BUTTONFIEL D BUTTONTYPE="Ima ge"

Any ideas on that?

Thanks,
Steve
The RowCommand autopostback has the row number (e.CommandArgue ment) and you
can use that to access a cell that has the id as in
GridView1.Rows[nRow].Cells[nCell].Text Sometimes instead of finding a
control that holds the id it is easier to just add the id as an extra column
and use the css style to hide it since it is not used except to make the id
easier to get access to.

If you want to do this on the client side and avoid a postback then during
the RowDataBound you can add something like

strVal = " WHERE id=" + e.Row.Cells[vFieldNum].Text;
e.Row.Cells[nFieldNum].Attributes.Add ("onclick", "return
LaunchInfo('./DetailLocation. aspx?sqlDetail= " + strVal+ "\')");

However, it would seem that what Siva suggested should work also
--
=============== =============== =============== =============== ==========
Joseph "Beemer Biker" Stateson
http://ResearchRiders.org Ask about my 99'R1100RT
=============== =============== =============== =============== ==========

:

Nov 26 '07 #4

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

Similar topics

5
3241
by: Fernando Lopes | last post by:
Hi. I want to show an image in a requiredfield validator instead of "*". So, I 'm set the requiredfieldvalidator attributes like following: <asp:RequiredFieldValidator id=rfvFirstName ControlToValidate="AddressName" Display="Dynamic" ErrorMessage="First Name Is Required" Runat="server" CssClass="AlertText"
0
2933
by: nx-2000 | last post by:
ASP.Net 2.0. I've got a GridView, its got a DataKeyNames set to the ID of the item that's in a row. I added a ButtonField column, made it a Button type with my "Remove" text, and when I hit the button, my CommandArgument in the RowCommand event is my ID field. Now, when my boss tells me that he wants a little delete picture instead of the word Remove, I go back, change the ButtonType property to Image and set the ImageUrl. When I...
1
2233
by: shapper | last post by:
Hello, I created an Hyperlink field in a GridView but I can't find and ImageUrl property. I know normal Asp:Hyperlink control can also be used with an Image. Is this possible in GridView? Then I tried to use a button field but I can't see a way to build the NavigateUrl as I need and as you can see in my Hyperlink button:
2
4255
by: Dale | last post by:
This seems like it should be simple and I am pretty sure I've done similar things a hundred times before but I sure can't seem to get it right this time. I have a GridView with a column of text boxes. If I want to position an image over the GridView just below, for instance, the textbox in row 4 of the GridView. I don't care that it covers the other textboxes. I am successfully obtaining the textbox and the image objects in client-side...
0
1511
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
I'm using a GridView to display large search results, and in each row I display a "Select" image button to choose the record. What I've been noticing is that when users search and display the results, the images for the buttons are not displayed all at once, but as if the page was downloading each image one by one, which is an unpleasent look and feel for the users. So, I checked my temporary Internet files and sure enough the same image...
3
2070
by: dhaneshrs | last post by:
I have a gridview i managed to update using the edit option in the smartmenu. The problem comes when i delete a value or make a value read only. Say i have a table Employee with the following columns : EmpID, Emp Name, Password, Emp Type. Now when i remove the value EmpID, the gridview does not update. it just reloads when i hit update but no changes are made. On the other hand say i make Emp Type as Read only, when i update .. the...
14
91376
by: Mike | last post by:
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 N-35 Mercedes 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...
4
1666
by: mik | last post by:
I've a gridview with a DDL in each row and I would like allow the user to open a new page (using a server button, image button, hyperlink... this isn't a problem) with the selected value of the DDL of the row I've tried with a a hyperlink... but I don't know how to use the selected value of the row
2
1304
by: doanthithanhnhan | last post by:
I'm working with GridView. But it seems rough. When I add a Command Field (Edit, Update image button type) handly. The OnRowUpdating doesn't fire when I click on Update button. Then I change by delete the Command Fiel I've created and use AutoGenerateEditButton property of the GridView and it does work. The function OnRowUpdating does fire. But I've got another trouble with this way. I can't get the changed value of the textbox in...
0
10639
Oralloy
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...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
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,...
0
10120
tracyyun
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...
0
9200
agi2029
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...
1
7661
isladogs
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...
0
5550
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...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.