473,394 Members | 1,567 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,394 software developers and data experts.

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 4499
Using PostbackUrl property:

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

Hope this helps?

"gl****@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
Nov 26 '07 #2
On Nov 26, 2:42 am, Siva M <shiva...@online.excite.comwrote:
Using PostbackUrl property:

<asp:ImageButton 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:BUTTONFIELD BUTTONTYPE="Image"

Any ideas on that?

Thanks,
Steve
Nov 26 '07 #3

<gl****@gmail.comwrote in message
news:e1**********************************@g30g2000 hsb.googlegroups.com...
On Nov 26, 2:42 am, Siva M <shiva...@online.excite.comwrote:
>Using PostbackUrl property:

<asp:ImageButton 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:BUTTONFIELD BUTTONTYPE="Image"

Any ideas on that?

Thanks,
Steve
The RowCommand autopostback has the row number (e.CommandArguement) 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
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...
0
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...
1
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? ...
2
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...
0
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...
3
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...
14
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 ...
4
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...
2
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.