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?


1/23/2007 2:20:46 PM 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 2


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 CommandField buttons (Select, Edit, Update, Cancel, Delete) to perform your data operations.

Robert Kafarski,

Aure Entuluva!
- Day shall come again!
1/23/2007 7:58:12 PM

You can create your clickable GridView control . This can be used to customize selections a user can make with the control.

Best Regards,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
1/24/2007 7:05:02 AM

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

adding custom linkbutton to gridview rows, that will update specific row in DB on click, PLEASE HELP!
i'm using a gridview to display results from a DB and I've added a custom column with a linkbutton in it, that when clicked, I want to update a particular column for that rowi've simply dragged a gridview onto a page, setup the SQL configuration, added a new column, turned it into a template, dragged a linkbutton onto it, double clicked it to get to code-behind and wrote this for the button click: protected void LinkButton1_Click(object sender, EventArgs e)    {        SqlDataSource filesupdate = new SqlDataSource(); &nb...

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="Summary" HeaderText="Item Description" SortExpression="Summary" ></asp:BoundField> <asp:TemplateField> <ItemTemplate> <asp:GridView ID="SitePrepDetailGV" runat="server" AutoGenerateColumns="False" DataSourceID="SitePrepDetailsDS" ShowHeader="False" OnRowCreated="SitePrepDetailGV_RowCreated"> <Columns> <asp:TemplateField ShowHeader="False"> <ItemTemplate> <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/assets/images/icons/EDIT.GIF" Text="Edit" OnClick="ImageButton1_Click" CommandArgument="e.Row" OnCommand="ImageButton1_Command" OnPreRender="ImageButton1_PreRender" /> </ItemTemplate> </asp:TemplateField> </asp:TemplateField> </Columns> </asp:GridView> </ItemTemplate> </asp:TemplateField> </Columns> </a...

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 also contain dropdown list (items are hardcoded with just few values like 'Less Than','Greater Than' etc.)    Column 4: The Column header here is "Value" and  it should contain textbox    Column 5: The Column header here doesn't contain anything, only buttons with cross symbol (x) are there under the header (inside the gridview) as the column values.Now the requirement is that, when we click the + button (which is in header of first column of gridview), it should add ONE row (at a time) in gridview and that row should contain the controls as specified above for Columns 2,3, 4 & 5. Similarly, when the cross (x) button (in Column 5) from any row is clicked, that row should be deleted.The problem could be easily explained if I would be able to show a reference/sample screenshot here. If anyone can help me with this, I can ...

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

Updating and binding control to other controls within the same row of a GridView
HiIn the EditTemplate of my GridView I show 2 DropDownLists. When the user selects the first dropdownlist, I need it to update the contents of the second dropdownlist. I have my Subs that do this fine when not inside the GridView, but what is the correct way to do it whilst they are in the GridView?This is my current attempt that returns the error 'Object reference not set to an instance of an object'. I presume its related to correctly targeting the DropDownList in question? This is my GridView:<asp:GridView ID="GridView1" runat="server"  &...

Hide update button in gridview row after it has been clicked on once until the update is done.
 I want to hide from view the update button  in a gridView  after it has been clicked once.  The clients are clicking the update button multiple times resulting in a not found condition.  I really don't know javascript.  The code below was given to me.   When testing it does not appear that clicking the button a second time has any results but we would like them to stop clicking it all together.                               I would like to change this statement to hide the update button until updating is complete.  It is in a gridview.DirectCast(ctrl, WebControl).Attributes.Add("onClick", "return confirm('Record Updating.  Please do not click update button again.');disabled=true;") Below is the entire sub.    Protected Sub grdKWBSDAX_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles grdKWBSDAX.RowDataBound        'grab last column (the command column)         Dim cmdCol As Integer = grdKWBSDAX.Columns.Count - 1        For Each ctrl As Control In e.Row.Cells(cmdCol).Controls            Dim btn As IButtonControl = TryCast(ctrl, IButtonControl)  &...

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

Update GridView and display to client row by row
 Hi, I am working on a website in which I have to display the data using gridview. The requirement is initially the gridview will be displayed with certain data. Later when user clicks abutton then we need perform a complex operation on each which will take some time. Once the operation is completed we need to update the gridview with operation results.This process should done for all the rows in the gridview. Right now if the user clicks on the button the operation is being performed on all the rows and all the results are in the gridview at once. For all the operation to be completed it is taking lot of time and user is thinking that website is not responding. Please some one help me Thanks You can use an UpdatePanel woth the control UpdateProgress that show an image, or a modalPopup or other for comunicate at the user this long operation. an UpdatePanelAnimation: this answers your question, please select 'mark as answer' thanks!Andrea DottorMicrosoft MVP - ASP/ASP.NET Thank you andreadottor  The requirement is we dont want the user to wait for long period. We want to update the grid once an operation is completed on the row. I w...

Row updating, row updated confusion
Okay this is the first time I've ever had to do code behind for row updating logic in a gridview. So be patient with me if it's totally incorrect. Do I put the gridview rebind code in the Row Updating or Updated event?  Currently, I have it in both as I'm simply troubleshooting to try to get it to work.  With this code, not only is the record not updating but the record disappears from the gridview upon refreshing.Protected Sub GridView2_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles GridView2.RowUpdated ...

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

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 SubHowever, I have no clue on what should go in between.  Any help will be appreciated!Thanks in advance! 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-BrockDevelopMentor Exactly what I needed!Thanks!...

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

GridView control Updating modified Row
Hi,   I am working on a .NET 3.5 project using Gridview control. I have dropdowncolumn in my GridView control. User can change the selection in the dropdown. I want to update the modified rows to the Database. How to check if a row is modified in GridView? Thanks Ashok Hi Ashok, the GridView control has its own mechanism for updating and deleting rows.Have a look at this link: (Modifying Data in a GridView Web Server Control).  Much ado about nothing Hi ashok.k, You can use the RowUpdating event of the gridview to retrieve the updated value from the gridview when you are updating the row. Please look at the example below:   1 //Gridview row updating event 2 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) 3 { 4 GridViewRow row = GridView1.Rows[e.RowIndex]; 5 //read the new values. 6 string Name = ((TextBox)(row.Cells[1].Controls[0])).Text; 7 string Age = ((TextBox)(row.Cells[2].Controls[0])).Text; 8 string City = ((DropDownList)(row.Cells[3].Controls[0])).SelectedValue; 9 //update database 10 UpadateNewData(Name, Age, Active); 11 } 12 13 //My method to update database 14 public void UpadateNewData(string Name, string Age, string City) 15 { 16 //database update here 17 }   Here I have used two t...

update rows using gridview control.....
Hello all, I just posted a message yesterday, there is no one replied to me. So i post it one more time, becuase it's really urgent. And i have read a lot from MSDN, and i followed exactly like what it says, but i still can't edit the rows.... I really have no idea what to do? I just hope someone can give me a hand on this... my asp:gridview control and sqldatasource control are pasted: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Datakeynames="ITEMNMBR"         ...

question about updating a row? How to update a different row.
I will try to make this as simple as I can. k, here I go. I originally populate my datagrid with data. Then during the edit mode, I can populate information by an ontextchanged event, which is actually bringing in a new row (essentially). My problem occurs when I try to update the data. Since the row was originally populated with the data, it updates that row in the table. But since I did an ontextchanged, I want to update that row instead. Not the original row. If I do an update, then I have two identical rows of data in my table, but with different primary keys. How can I update t...

Changing the color of the Row in a Gridview on click of Radio Button in the Row
I have a GridView. One of its columns contain Radio Buttons. NOw on click of Radio button in a particular Row, I want to change the Background and Foreground Colors of that Gridview Row. Once the next Row is clicked, I want the color to change back to the original color. I am using the following template for Radio Button because of other functional requirement.                           <asp:TemplateField HeaderText="Select">   &nbs...

I have a gridview control how do i capture the row that I have clicked
I have a gridview and I want to capture the row that I have clicked and store the values of that row in some session so that i can place those row values in some other page. any help on this query would be highly appreciated. Hi, In the selectedindexchanged string s1 = GridView1.SelectedRow.Cells[2].Text;string s2 = GridView1.SelectedRow.Cells[3].Text;string s3 = GridView1.SelectedRow.Cells[4].Text;   HTH,Suprotim AgarwalASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks | Hosting your site? | SQL Server Tips thanks for your post agarwal. I want the value...

Update each row from gridview when submit clicked?
I have a gridview that displays a row of data for each row returned from my sql query.  Rather than forcing the user to click submit after making a change on each row of data, I want to have one submit button at the bottom that updates each row with the value entered for that row (in a text box).  How do I do this? Never make important decisions on a Monday! Loop through each datarows  of the Gridview.. get the values you want to send to the db using FindControl.. and execute the Update staetement..The code will be something likeforeach (GridViewRow grow in GridView1.Rows) {...

Allow editing of all rows simultaniously (without having to click edit/update for each row)?
I have an application where the user will be presented with perhaps 20 rows.  1 field of each row (the score) will need to be updated by the user.   Now with a gridview they would click on the first row's EDIT button then make the change for the Score field and then click update. Having to do this ~20 times would be somewhat annoying for the user :)  Is there any way I can get an Excel like behavior where the user can just click on the first row's Score field then enter the integer score and hit tab or down arrow or something and drop down to the next one and keep on moving until they are all edited? Similar to how in VS 2008 in the Server Explorer tab you can go Show Table Data and then all the fields let you edit them by just clicking on them?   Yeah, look at putting textboxes in the control instead of labels and handling the saving programmatically.  You should be able to do everything programmatically with the GridView control except custom paging.... then you would have to extend the control and throw in your own paging control to store the "vitrualitemcount".Joseph Baggett MCSD, MCPD: Web Developer, MCITP: Database Developer, MCTS: SQL Server 2005, MCTS: .NET 2.0 Web Applications, MCTS: .NET Framework 2.0 Windows Applications, MCTS: .NET Framework 2.0 Windows Applications, MCAD, MCP If the project doesn't work, blame Scott Guthrie and/or refer to the problem solving flowsheet. O...

Change color of gridview row when we click row checkbox clear when we unclick
Hi frinds//  I have question.. I needto change the color of gridive when we click checkbox in the gridview..sam time when we unselected selected checkbox it should come previous color can any one help me ASAP thanks..   hi, i'm not sure if you want the gridview to change color or the gridview row containing the checked/unchecked checkbox to change color upon selection. I assume the gridviewrow and as such i have written a small sample code. To try the sample, add a new .aspx page into your project and replace it's contents with the following code and run :  &l...

update data of get clicked row from gridview
I get clicked row from gridview to another page. I want edit and update that datas. but when I change the value and clicked update button. There is value be only from gridview no new entered value change. There is value = "" and datatype mismatch error occurred. What I do? What is solution?Endendrum Priyamudan P m R Hi try this example with Gridview protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)    {                //-- Get Album Data  &nbs...

skipping rows from update in a gridview web control
 Hi all,I have a gridview with one editable column whis has an item template field with a textbox bound to a datafield. So, the user can change all fields over all rows, without the need to press "edit"-"update" on each row seperately. Outside the grid view there is a button "update". When the user pusches this button theo following code updates the rows:            For i = 0 To gridview1.Rows.Count - 1                gridview1.UpdateRow(i, True)            Next This works fine. But with the update there is another field which is updated also with a given parameter. This should not happen, except for those rows, which the user has actually changed.My idea was, to  provide an RowUpdating-Event-Code like this     Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating       if e.OldValues("field1").ToString = e.NewValues("field1").ToString         .... do something to prevent the update      end if    End SubBut I get the message that e.OldValues point to "nothing". Obviously, this is, because I update the colums...

Web resources about - GridView update rows by clicking or doubleclicking a row -

Books - Scientific Wordprocessing for MacOSX
Scientific Wordprocessing Software for MacOS X, MathML based equation editor, LaTeX export, 2D Plots, Simulations

Start Mixing
Create Video Mixtapes in Minutes

0xPIT/reflowOvenController · GitHub
reflowOvenController - Reflow Oven Controller. See below for more information.

Preventing online attacks from unknown attachments - Kaspersky Lab Official Blog
When handling new or complicated attachment types from unknown senders, it is wise to always scan the downloaded attachment with an antivirus ...

Muckety help topics
Having problems seeing the interactive maps? Muckety maps are designed for Flash version 9.0 and higher. You may need to get the latest version ...

WABC Free Songs
Your Free Copyof the WABC Top Songs of the Year! (and thistime you don't even need a self addressed stamped envelope!) How would you like to ...

Lockerbie 2009
May 12, 2009. The Lockerbie Second Appeal finally got underway on April 28th, 2009, amidst significant controversy. Unfortunately Mr. Megrahi ...

Blogs Dashboard
An independent report filed on Friday in an Arkansas state court sided with Google and against disgruntled advertisers who had sued the Web search ...

Google Puts Clickfraud Rate At Under 2 Percent
Google Puts Clickfraud Rate At Under 2 Percent

40 iLife tips and tricks you may not be aware of
Cool iLife features you probably don't use

Resources last updated: 3/30/2016 7:21:12 PM