Get row info when an imagebutton on that row is clicked in a gridview

This is my gridview:

<asp:GridView ID="GridView1" runat="server>
   <Columns>
      <asp:BoundField ...>
      ...
      <asp:TemplateField>
         <ItemTemplate>
            <asp:ImageButton ID="Button1" ImageUrl=... runat="server" OnClick="Button1_Click" />
         </ItemTemplate>
      </asp:TemplateField>
   </Columns>
</asp:GridView>

This will give an imagebutton on everyrow of the gridview.  I want to be able to get the information on the row where the imagebutton is clicked.

I am guessing that I need to use gridviewrow in the following function:

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

However, I have no clue on what should go in between.  Any help will be appreciated!

Thanks in advance!

0
powerfu
8/9/2005 2:39:18 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
936 Views

Similar Articles

[PageSpeed] 22

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
   dim row as GridViewRow = CType(CType(sender, Control).NamingContainer, GridViewRow)
End Sub

-Brock

DevelopMentor
http://staff.develop.com/ballen
0
BrockAllen
8/9/2005 4:34:20 PM

Exactly what I needed!

Thanks!

0
powerfu
8/9/2005 10:49:36 PM
Reply:

Similar Artilces:

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Gridview row click event fires, when clicking on controls within row.
I have a gridview control and I have added  a row click event which causes a post back. e.Row.Attributes.Add("onClick", this.Page.ClientScript.GetPostBackEventReference(this, "Select$" + e.Row.RowIndex.ToString()));  When the user clicks the row, i bind some data to a checkbox list, showing a uers a list of options they have chosen. All good so far. I also have a edit button for each row. When the row is in edit mode i display a checkbox and textbox. Problem is when i click on the textbox or the checkbox, it causes the row click event to fire. Any ida...

How to delete row from GridView control
Hello,  I am working on an ASP.NET 2.0 app, and I am trying to wire up a "Delete" button to a gridview control on a form. Here is the code for the ASP :  <asp:GridView ID="gvInConditions" runat="server" AutoGenerateColumns="true" OnRowDeleting="gvInConditions_RowDeleting" DataKeyNames="Condition_ID" >         <Columns>                <asp:CommandField ButtonType="Button" SelectText=&...

How to find a outer gridview row when a button in inner gridview row is clicked
Hi, I have a gridview within a gridview. In the inner gridview, I have a column of imagebuttons. I cannot figure out how to find out the row of the outer gridview when I click on the imagebutton in the inner gridview. I modifies the code below to get rid of some of the unnecessary stuff. <asp:GridView ID="SitePrepMainGV" runat="server" DataKeyNames="SitePrepItemID" DataSourceID="SitePrepMasterDS" OnRowDataBound="SitePrepMainGV_RowDataBound" OnRowEditing="SitePrepMainGV_RowEditing" OnRowCreated="SitePrepMainGV_RowCreated"> <Columns> <asp:BoundField DataField="S...

Adding row (one at a time) in gridview on a button click. And cells of added row should contain controls like DROPDOWN LIST or TEXT BOX.
Dear Friends, I am in great need for the solution/hints/guidance of my requirement, if anyone can help with.  Let me explain what I need."I need a Gridview control on a webpage having following 5 columns/fields.     Column 1: It just has a "+" button in its header only (other cells for this column is empty)    Column 2: The Column header here is "FIELD" and  it should contain dropdown list (which is populated from some database)    Column 3: The Column header here is "Operator" and  it should ...

Data Controls insert rows into gridview then insert rows from gridview into SQL Table
Hello there, I'm still new at performing miracles with code . Currently I am having trouble with my latest coding adventure I have a web application which records jobs and labour assigned to jobs. The issue in particular I'm having is the way in which labour is to be assigned. I want to use standard controls (Textbox, Dropdownlist) to record the values into a gridview (ie,put multiple rows into the gridview using the controls). Then, when all the inserting is complete, the user clicks a submit button to insert all the rows from the gridview into a database table. The reason for...

GridView update rows by clicking or doubleclicking a row
I have created a Gridview control and programmatically set a row into edit mode when a user clicks on a row by implementing the rowcommand event. If the user changes any of the column values I catch the Textchanged event and the database gets updated with the new values. I would like to update the rows even if there is no change in any of the columns - what event should I implement? Thanks. Hey, What is the reason for updating database if you actually do not change anything? And using TextChanged event to invoke postback everytime you type in a letter is even worst. Use C...

Find the row number on click of a gridview row???
Hello everyone,I need to find the gridview row number on click of a row on Page_load not on any other event..!! How do i do that?Please help me..!!regards,Francis P. Ferns Sorry Francis, but I believe you're out of luck as the Page.Load event is way too early in the Page lifecyle to pick this up. This would most likely be done in the SelectedIndexChanged, RowCommand, or Click event of a Button.Thanks, EdMicrosoft MVP - ASP/ASP.NET Hi,Ya i understand that. Is there any other way i can find out the Row number.I ll tell you my actual requirement.Im implementing the ICallbackEventHa...

does anyone know how to do that, when I click the last row of the gridview, the gridview will automatically add an empty new row for me.
does anyone know how to do that, when I click the last row of the gridview, the gridview will automatically add an empty new row for me.   thanks hi there,the only I could think of for now is is enbale footer rowthen hide it onpageload so when last row click set footer.visible to true  ...

How to get the row index of a selected row in listview control
Can someone please tell me how to get the index of a selected row in a listview.  <ItemTemplate> <asp:LinkButton runat="server" class="linkButton" id="xxxxx" Text='<%#Eval("documenttype") %>' CommandName="OpenFile" CommandArgument='<%#Eval("DocumentKey") %>'></asp:LinkButton></ItemTemplate>what you have to do is, in itemcommand event of ListView, you have to get the value of row indexif(e.CommandName == "corrospondingcommaandname"){     &nb...

how to get id of row from check box in gridview row
this is my gridview code   <asp:GridView ID="dgAssociatedAttributes" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Width="80%"> <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> <Columns>           <asp:Bound...

Gridview Rows Backcolor getting reset when selecting a row
I have a list of rows in my gridview that list one or more entries per date.  I have coded the RowDataBound event so that all of the rows for a given date have the same backcolor.  Day 1 is white, Day 2 is yellow, Day 3 is white, day 4 is yellow - where each day could have multiple rows.  On each row, I also have an Edit imagebutton that allows each row to be edited via a separate panel and not in-line grid editing.  When I click on the Edit imagebutton, I set the gridviews selectedindex to that row and then using the skin for the grid, the selected row backco...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row.
What is the best way to show a gridview row highlighted once selected and keep it highlighted once the mouse moves over a different row? Thanks, Steve hi,you can use <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" /> plz let me know if i misunderstood you Thanks for your help. One problem; however, is that after the row has been selected and I check the "grid.SelectedIndex" it has a value of -1 and not the index of the row that was selected on the grid. What do you recommend? Thanks, Steve hi, sorry i din...

Web resources about - Get row info when an imagebutton on that row is clicked in a gridview - asp.net.presentation-controls

Hottest 'android-resources' Answers - Stack Overflow
current community chat blog Stack Overflow Meta Stack Overflow Stack Overflow Careers your communities Sign up or log in to customize your list. ...

Short Circuits and Infinite Loops
I was able to get the Android client up and running last night. It's a fairly simple affair, since I am definitely an Android GUI newbie, but ...

Image view with long press hint
Image view with long press hint - Gist is a simple way to share snippets of text and code with others.

ButtonExtensions Module
AddConfirmation() This Extension Method extends the Button, ImageButton, and LinkButton by adding a JavaScript confirmation dialog that appears ...

Wazapp for Nokia N9 gets major update. Bumped to version 0.9.12.
It has been long since we covered some Nokia N9 related news on our blog. But can’t resist reporting this. Wazapp the fruit of hard work put ...

Java AWT - Real's HowTo
Real's HowTo Custom Search Java Language String and Number Applet AWT Swing Environment IO Javascript interaction JDBC Thread Networking JSP ...

Android ListView with custom layouts tutorial
private void updateList(final ArrayList items){ listLayout.removeAllViews(); LayoutInflater inflater = getLayoutInflater(); if (items.size() ...

Resco releases two new, imaging-related controls
... that want a graphical button like the ones found in Palm OS applications) will be delighted to hear about Resco’s new controls. The ImageButton ...

WinCDEmu - Opens ISO and CD/DVD Images
Do you know what ISO files are? How about CUE, NRG, MDS/MDF, CCD, or IMG files. These are CD or DVD image files and they can be opened if you ...

Recipes - Xamarin
Xamarin Menu Products Xamarin Platform C# on iOS, Android, Mac & Windows Xamarin Test Cloud Test any app on hundreds of devices Xamarin University ...

Resources last updated: 12/7/2015 2:59:17 PM