473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

GridView: Retrieve a value via ImageButton

Cem
Hi,

in GridView1 I have following code:

<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%#
Eval("airport_active", "images/icons/ico_airport_active_{0}.gif") %>'
ToolTip="Aktivieren / Passivieren" OnClick="ImageButton1_Click"
CommandArgument='<%# Bind("airport_ID") %>' />
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("airport_ID")
%>' Visible="False"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>

After clicking ImageButton1 I want do some action (first a simple
response.write(airport_ID) and later a stored procedure thing)

How Do I retrieve my airport_ID either from the ImageButton1 or the
TextBox3?

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
????
End Sub

Thanks in advance.

Kind Regards,

Cem

Sep 26 '06 #1
1 2911
Hi,
Instead of using the ImageButton Click event handler, put uor code in the
GridView RowCommand event handler but first set the CommandName property on
the ImageButton.
Your code will be somthing like this
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%#
Eval("airport_active", "images/icons/ico_airport_active_{0}.gif") %>'
ToolTip="Aktivieren / Passivieren" OnClick="ImageButton1_Click"
CommandArgument='<%# Bind("airport_ID") %>' CommandName="ImageClick"/>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("airport_ID")
%>' Visible="False"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>

protected void grd_RowCommand(object sender, GridViewCommandEventArgs e)
{

Response.Write(e.CommandArgument.ToString());
}

Regards,

Mohamed Mosalem

"Cem" <go****@e-babil.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi,

in GridView1 I have following code:

<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%#
Eval("airport_active", "images/icons/ico_airport_active_{0}.gif") %>'
ToolTip="Aktivieren / Passivieren" OnClick="ImageButton1_Click"
CommandArgument='<%# Bind("airport_ID") %>' />
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("airport_ID")
%>' Visible="False"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>

After clicking ImageButton1 I want do some action (first a simple
response.write(airport_ID) and later a stored procedure thing)

How Do I retrieve my airport_ID either from the ImageButton1 or the
TextBox3?

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs)
????
End Sub

Thanks in advance.

Kind Regards,

Cem

Sep 26 '06 #2

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

Similar topics

2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
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: NH | last post by:
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...
0
by: Innova | last post by:
Hi, We are working on a gridview inside the gridview (parent-child) scenario. The data of child grid will depend on the data of parent. Objectives: 1.Add new row in parent grid after each row...
0
by: Kyle K. | last post by:
(Note: Windows XP Pro SP2 + Visual Studio .NET 2005 + SQL Server 2000) I have a GridView that is populated with data. That last 2 columns are button fields (image buttons) that have a CommandName...
0
by: Stan SR | last post by:
Hi, I need to customize a pargertemplate with these items a arrow to go back to the 1rst page a arrow for the previous page a dropdownlist with the page indexes a arrow for the new page a...
0
by: cmrhema | last post by:
Hello, I am having a problem with GRIDVIEW IN C#. The following code updates only the alternate rows. When i use the edit button all the cells does get converted to textboxes thereafter when i...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
3
by: glbdev | last post by:
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
1
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...
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...
0
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,...
1
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...
0
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...
0
muto222
php
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.