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 idaes anyone?

 

Thanks,

 

Shaz

 

0
Shazman
5/17/2007 4:40:00 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
2423 Views

Similar Articles

[PageSpeed] 13

Hi Shaz,

I'd try only adding the onclick event if the row is not in edit mode, like

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
 if ((e.Row.RowState & DataControlRowState.Edit) == 0)
 {
  e.Row.Attributes.Add("onClick", this.Page.ClientScript.GetPostBackEventReference(GridView1, "Select$" + e.Row.RowIndex.ToString()));
 }
}

Hope that helps.

Aaron

 


Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved so everyone will know you have been helped.
0
agolden
5/18/2007 4:21:23 AM

Thanks Aaron, works a treat, I had the same idea last last nite.

 

thanks again,

 

Shaz 

0
Shazman
5/18/2007 2:04:39 PM
Reply:

Similar Artilces:

I've added button withevent into row of gridview but when i click it , click event didn't fire.
I've add button withevent in empty row of gridview but when i click it , click event didn't fire. what's worng is it? My code is: Partial Class dc_so Inherits System.Web.UI.Page Dim WithEvents btnAdd As New Button Dim txbSoId As New TextBox Dim txbCartonName As New TextBox Protected Sub gvSo_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvSo.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then ' check for empty data If Convert.ToString(DataBinder.Eval(e.Row.DataItem, "so_id")).ToString.Trim = "" Then btnAdd.Text...

When i click gridview row page laod event fire
I have dropdown list. When i change value of drop down gridviw value is  change according to drop down value.  after that there is link in datagrid. when i click that link it open new page.  Problem is when click first time in gridview its fire page load event. Second time click its open new page. If i change value again in drop down same senario happen. first time gridview click run page load. Why that, how can i solve it? lakmal   http://www.odesk.com/users/ASP-NET-Web-application-Designer-DotNetNuke-Expert_~~4fc245f3b8e64e9b Hi, you didn't pr...

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 ...

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 ...

Iwant to select a row and column in gridview with select radiobutton. but No checked change event.below put a button .if click that button to seleced row values will select
I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page im using this code .but im getting one column in that row. but i want all columns in that selected row so plz repla...

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...

ctrl-click shift-click for GridView rows
Has anyone extended the GridView control so that ctrl-click and shift-click works for selecting rows?  The Select CommandField column is a bit cluncky from a user perspective.  It seems a user should be able to select a row anywhere (in any column) and use common Microsoft commands (shift-click, ctrl-click) if selecting multiple rows. If you would like ctrl-click and shift-click to work for selecting rows, you need to write a custom GridView which inherited from System.Web.UI.WebControls.CompositeDataBoundControl. Try to take a look at this link about a...

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...

Click event available to web control within user control? How?
I have a main .aspx page.  I am using code behind, developing with Visual Studio Pro 2003.  I have a user control (.ascx) on my main page.  Inside that user control are web server controls (namely LinkButtons).  I want to have all the LinkButtons to point to one click event.  That click event will identify the LinkButton by its ClientID and perform an action accordingly.  Within the LinkButtons, do I type OnClick="myClickEvent"? Where (in what .vb file) do I put the click event and how do I point all the LinkButtons to fire it when clicked. If I doub...

Gridview Event : image button's row command fire second time when i do refresh or postback after clicking on imgdelete button immidiatly
 i am getting  imgDelete (image button) row command fire second time when i do refresh or postback after clicking on imgdelete button immidiatly, so how can i prevent(handle) it from firing second time.it is a user control   fun.ascx.vb Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load                       If IsPostBack = False Then            FillGridView()   &nbs...

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  ...

Table Cell click event
Hi, I used to have a custom server control inhirted from TableCell control to implement click event in VS.NET 2003.  When I use the custom control in VS.NET 2003 Web application (dynamically adding to table object), everything works fine.  Below is the code from 2003 project, and everything works good in this way.                 Dim c As New MyCustomTableCell                  c.Width = 200     &nb...

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>    ...

Web resources about - Gridview row click event fires, when clicking on controls within row. - asp.net.web-forms

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 12/24/2015 1:35:01 AM