Edit GridView row data

When a user clicks on the "Edit" control, I need to copy the data before the row goes to Edit mode.  I am trying GridView_RowCommand Event but I can't assemble the code to copy the row data, or cells in the row, where the Edit control resides.  What Event do I use to do this and what code will copy the row that the "Edit" control was in?

0
mjta
3/31/2009 2:24:33 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

9 Replies
599 Views

Similar Articles

[PageSpeed] 17

can u plz explain why do u need to copy row data before going to edit mode?

0
Mahwish
3/31/2009 2:39:32 PM

I am working on a way to audit data changes.  I'm not sure of the best approach yet so I had to start somewhere.  I want to compare old values to new values and if there is a change, Email the comparison to the user.  So I figured I would copy the row data before Edit and Copy data after Update and compare the two for any change.  I have a sql trigger in place but I'm trying to come up with the best way to get the changes emailed to the user in the best format.

0
mjta
3/31/2009 2:56:06 PM

I am not very sure, but I think you want to capture the row of a Grid, when a user clicks it.

you can use the SelectedIndexChanging event for that. something like this:

protected void SearchResultsGrid_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)

{

Label lbId = (Label)SearchResultsGrid.Rows[e.NewSelectedIndex].FindControl("LblData");

String Id = lbId .Text;

}

please let me know if this helps.


Ashu Agarwal
Please “MARK AS ANSWER” if my post helped you.
0
ashuagarwal
3/31/2009 2:56:13 PM

as i think u will need to make the comparison after user clicks update button of row. if this is the case then u can do tht thing in RowUpdating event of gridview. In this event, get old value of data of the row programmaticaly in code behind because by tht time row wil not be updated with new values, store these values somewhere. Then get new data from controls in edit mode of gridview row, compare them and then update the row.

0
Mahwish
3/31/2009 3:07:24 PM

yes, copy the row, or the data of the row, when a user clicks on the Edit control of that row.  That's one of the main issues...is when Edit is clicked, not when Select is clicked.  I want to either cache or put in session the values.  I think session will be the way to go and I can cancel the session when the compare is completed.

 

0
mjta
3/31/2009 3:10:44 PM

I am trying to understand how to get the values when the Edit button is clicked...

0
mjta
3/31/2009 3:21:23 PM

lbId is a label on the page.?  Right?  Also, elaborate on String Id.  What does it represent?

0
mjta
3/31/2009 3:24:44 PM

I want to say...ok...if the user clicks Edit on a particular row.  What are the values in that row?  Take those values and put them somewhere.  Then, if the row is updated, compare the new values to the ones that were stored somewhere.  If any are different, then put those values somewhere to be stored and emailed.  Otherwise, if the user Cancelled the Edit, then disregard the original values that were stored.

0
mjta
3/31/2009 3:30:01 PM

actually,Lbldata is a column-label on the gridview. In the example, you are getting the value of that column on a dynamic label which is lbId. the value of that label is stored in String Id. following is the example gridview:

<asp:GridView ID="SearchResultsGrid" runat="server" "

AutoGenerateColumns="False"  EnableViewState="true"

EmptyDataText="--- There are no data ---" EmptyDataRowStyle-Font-Italic="True"

SelectedIndex="0"

 

Width="760px" onrowdatabound="SearchResultsGrid_RowDataBound"

onselectedindexchanging="SearchResultsGrid_SelectedIndexChanging"

PageSize="50" >

<PagerSettings Mode="NextPreviousFirstLast" PageButtonCount="20" />

<EmptyDataRowStyle Font-Italic="True"></EmptyDataRowStyle>

<Columns>

<asp:TemplateField HeaderText="Address" >

<ItemTemplate>

<%#Eval("Address")%>

</ItemTemplate>

<HeaderStyle HorizontalAlign="Left" />

<ItemStyle HorizontalAlign="Left" />

</asp:TemplateField>

 

<asp:TemplateField HeaderText="" >

<ItemTemplate><asp:Label ID="Lbldata " runat="server" Text= <%#Eval("LocId")%> Visible="false" /></ItemTemplate>

<HeaderStyle HorizontalAlign="Left" />

<ItemStyle HorizontalAlign="Left" />

</asp:TemplateField>

</Columns>

</asp:GridView>


Ashu Agarwal
Please “MARK AS ANSWER” if my post helped you.
0
ashuagarwal
3/31/2009 3:32:50 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 ...

how to edit rows in the gridview contol in windows form using vb.net
 hi, I'm neha and can anybody pls tell me how to edit the rows listed in gridview control in windows form using vb.net Its urgent . Thanks,Neha  In this lesson, you will learn about the GridView and FormView controls and how you can use some of the features of these controls to make editing and displaying of database content easier http://www.asp.net/learn/videos/video-07.aspxPlease remember to click “Mark as Answer” on the post that helps you nehakhanna:gridview control in windows form These forums are for ASP.NET (web sites / web applications), not wind...

Gridview row editing fields based on row data
Is there a way to change row editable fields in a databound gridview based on the rows data. For example letting a user edit all his and his fellows fields but preventing him from changing specific fields in his boss data on the same gridview? Help will be great fully appreciated. Thanks If I understand what you are saying is that you want to only allow a user to Edit certain rows within the GridView. If so, yes, you certainly can do this. What I would do is hide/display the Edit Button for a row based on the user's role or permissions. This can easily be done via the RowDataBound e...

How to get the data of a particular row in gridview without editing that row.
I have a gridview in a page in that ihave hyperlink as one column on click of that i want to go next page with the data present in that corresponding row. How shell i read the data from grid view for that pirticular row.On which event i can get the data. HI, the row that is selected should be passed into a string or an array or in sessionsthis can be done through this code  protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)    {        Label _lbl = new Label();      &...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

Submit Form to insert data into SQL and display with a gridview (edit as well) below how do i insert data into sql table?
I have an asp.net page that has a simple form where a user can submit customers information. Below that I have a gridview which displays customer information submited by the user who is logged in. I have the gridview displaying, sorting and updating as I want however I can't figure out how to bind a button click to insert data into the customer table and then have it refresh the gridview when they submit. Here is the basic code; (I am using AJAX for a calendar when a user wants to edit an appointment date) &lt;div class="leftBar"&gt; <div align=center&...

After hitting update on gridview, data changes but gridview still shows the update and cancel links for edited row
Really weird. I click the update link after I change the input data. I debug through it and it shows that the update is complete but then when OnRowUpdating function is done the update and cancel links are still there. What else do I need to do.. Here is the code. ASP:  <asp:GridView ID="OOWSecAuth" runat="server" AutoGenerateColumns="false" ShowFooter="true" AutoGenerateEditButton="true" OnRowEditing="OOWSecAuthEdit" OnRowUpdating="OOWSecAuthUpdate" ...

Submitting data from a know web form to unknown web form
hi i m making a software in which i will submitt some data from a web page that will go to a web form of which contrlos are unknown to me only i know the name and how many controls in that form it means i can see the form only. how can i do this please help me soon with code plz its very argent.i m doin this wit the help of foxtrot.xray.WebRobot but its giving me error that this dll file is already exists in The file ('C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\_foxtrot.xray.WebRobot.dll' already exists).i don know what will do so please help me soon please thanks praveen We ca...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Editable GridView: Need C# code for Editable Gridview web part..!!
  I have created a Sharepoint Web Part programmatically in C# which fetches data from SQL database and displays in a Gridview. Its working fine. Now i need to make this gridview editable so that the changes should be reflected / saved back into SQL Database. I am running oout of time and need help immediately. Can somebody help me in getting the code for Editable Gridview please........???? Thank you Can Sombody help me out here.......... there are so many examples on the web http://msdn2.microsoft.com/en-us/library/ms972948.aspx http://www.experts-exchange.com/Programming/P...

synchronizing chunk of data of one web form for another web form
I'm making a web application. In one web form; i'm taking inputs from user. Now; there is some info given by user in this page which is needed for web form which is going to be displayed next. i want to display that info automatically on that web form so that user doesn't have to re-input that info in this next web form. Info from first page would be inserted into database when user clicks on the submit button. then that next web form would be displayed. and the chunk of info from previous page should be displayed there!!! how can i do this?? cany anybody help?? nobody can help me!! I...

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

VS.NET Web Data Form Wizard
New to asp.net and using the Web Data Form Wizard. Cannot get the datagrid sort or paging functions to work. Do I need to add code for this manually? When selected both options just reload the main page. Thanks, SCott Check out the following two MSDN articles: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconintroductiontodatagridwebcontrol.asp and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingsortingtodatagridwebcontrol.asp bill "This posting is provided "AS IS" wi...

Not Retreive GridView Rows to Another Web Form
Hi i am doing on asp.net application.in that i am accessing data from ObjectDataSource. i want to reterive rows to another page.i need these rows values to another web form..i am using HyperLinkField get one value data DatanavigateField and dataNavigateUrlFormatString="ShowCorp.aspx?corpcode={0} and another page i reterive using Request.QueryString it is coming only one value is coming at the dame i tryed but i need all rows values can any one help me..pls      Thanks rambhopal reddy Regards Rambhopal Reddy EPlease remember to click “Mark as Answer” on the ...

Web resources about - Edit GridView row data - 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: 11/25/2015 2:21:34 AM