Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
<asp:GridView ID="GridView1" GridLines="None" BorderStyle="None" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns >
<asp:TemplateField ControlStyle-BorderStyle="None">
<ItemTemplate>
<table class="Panel ArticleSummariesPanel ViewCategoryArticleSummariesPanel" border="0" width="100%">
<tbody>
<tr>
<td height="98" class="normaltext">
<div class="Item_knock">
<span ><a href="JobInterview_Details.aspx?WID=<%#Eval("WalkinID")%>" target="_blank" class="jobbigtext"><%# Eval("Walkin_Title") %>--Exp.[<%#Eval("Exp")%>]</a></span>
<div class="Details"><strong><%#Eval("Company_Name")%> </strong> <br /><strong>Skills :</strong><%#Eval("Skills")%></div>
<div class="Content_knock">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="Content_knock" width="850" valign="top" align="left">
<strong>Job Location :</strong><%# Eval("LocationName")%></td>
<td class="Content_knock" width="550" valign="top" align="left"></td>
<td>
<asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" ImageUrl="~/images/apply.png" runat="server" /></td>
</tr></tbody>
</table></div></div></td>
</tr></tbody></table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
 
I have a lot of jobs list in gridview..I need to pass a id when user click a particular job imagebutton...How can i do that?
Posted 14-Aug-13 1:29am
Edited 14-Aug-13 1:40am
v3
Comments
sisir patro at 14-Aug-13 7:35am
   
Hv you tried anything?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Add commandargument property
Use OnCommand instead of OnClick
 
<asp:imagebutton id="ImageButton1" oncommand="ImageButton1_Command" imageurl="~/images/apply.png" runat="server" commandargument="<%#Eval("ID")  />
 

In ImageButton1_Command event you get ID
 int ID = Convert.ToInt32(e.CommandArgument);
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

You can set Id to Imagebutton's CommandArguement Property:
 
<asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" ImageUrl="~/images/apply.png" runat="server" CommandArguement='<%# Eval("Id")%>' />
 
You can get Id on server side Imagebutton click event :
 

ImageButton ib = (ImageButton)Sender;
Int Id =int.Parse(ib.CommandArguement);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Example of gridview rowcommand on Button Click [^]
Above link will guide you how to work with grid view command
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
You can do it using the GridView_RowCommand(). Follow the following link here.
 
Thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Very simple you can give a commandname to the image button and code on the GridView_RowCommand event where you can also find the control that cantains the id field or if you using datakeys then still you can find datakey very easily....
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Use CommandArgument attribute of the ImageButton to set the value and use gridView's RowCommand event to track which button is clicked (using EventArgument value).
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Nirav Prabtani 384
1 OriginalGriff 289
2 Sergey Alexandrovich Kryukov 225
3 _Amy 195
4 Kumarbs 144
0 OriginalGriff 7,799
1 Sergey Alexandrovich Kryukov 6,966
2 Maciej Los 3,994
3 Peter Leow 3,708
4 CHill60 2,742


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 16 Aug 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100