GridView: Retrieve a value via ImageButton

C

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
 
M

Mohamed Mosalem

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top