.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

GridView Rowupdating Returns old Values

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net

Haii all, my gridview row updating events return old values.. edititem templatefield gets its old value on row updation.

My code is as follows :-

      protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)

        TextBox tb1 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt3");
        TextBox tb2 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt4");
        TextBox tb3 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt5");
        TextBox tb4 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt6");
        TextBox tb5 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txt7");

        string s1 = tb1.Text;
        string s2 = tb2.Text;
        string s3 = tb3.Text;
        string s4 = tb4.Text;
        string s5 = tb5.Text;

        string qry="Update SparePartsStatus set Equipment='"+s1+"',Location='"+s2+"',TotalQuantity='"+s3+"',DateofDelivery='"+s4+"',Balance='"+s5+"' where (SpareName='"+Session["partno"]+"')";
SqlCommand com=new SqlCommand(qry ,con);
        int d = com.ExecuteNonQuery();


View Complete Post

More Related Resource Links

update parentpage gridview with the values from child page?


hi   i am having a gridview on each row i am having a update and add button.

on click of either of the button i am opening a popup where the end user will enter data and on clck of ok button in the child page

based on the click ie

if i clicked update i need to update that particular row with the values from child page.

if i clicked on add i need to add a row below the row where i clicked add button .

can anyone help me with this?

Get values of row in a gridview


Hi everyone

I have a problem that can't find a way to do it, I have a gridview with this columns:

ID  |  AreaName  |  CostCenter

with the "Enable Editing" option check and what I want to do is to get the values of areaname and costcenter and assign them to a label control so I can use the values for something else, for example:

ID        AreaName       CostCenter

1          Multiconector   1025

2          One Conector   2065

3          Plug & Play       1445

hsdsd: how to insert two values from text box1 to gridview g



table a

a                                 b

jhgd                           kljhskjd

sdghdshgd                 jkhdjhdjk

what i need is when enter some values(varchar ) in txt 1 and 2

it should be added in database and shown in gridview1 after i press butt1


any bodyknows full code answer/akdj

GridView RowUpdating event

Hi,I have a gridview. In the rowupdating event, the txtbox returns null. I have enabled viewstate for the gridview. But still it does not work. I have made this in Kentico. Please help.<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"        AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" EnableModelValidation="True"        OnRowUpdating="GridView1_RowUpdating" >        <Columns>            <asp:CommandField ShowDeleteButton="True" CausesValidation="false" ShowEditButton="True"                ControlStyle-Width="100px" />            <asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Name" SortExpression="name">                <ItemTemplate>                    <as

gridview help on each dynamic row solve this show values based on all columns

<asp:GridView style="Z-INDEX: 101; LEFT: 1px; POSITION: absolute; TOP: 183px" id="Gridview1" runat="server" Width="613px" Height="127px" ForeColor="Teal" Font-Size="12pt" Font-Names="Palatino Linotype" Font-Bold="True" Visible="False" BorderColor="Transparent" AutoGenerateColumns="false" CellSpacing="2" GridLines="None" OnRowCreated="Gridview1_RowCreated" SelectedIndex="5" ShowFooter="true" OnRowDataBound="Gridview1_RowDataBound"><Columns>  <asp:TemplateField HeaderText="ItemCode"><ItemTemplate> <asp:DropDownList id="DropDownList1" tabIndex=16 runat="server" AutoPostBack="True" DataValueField=" ItemCode " DataTextField=" ItemCode" ></asp:DropDownList></ItemTemplate></asp:TemplateField>  <asp:TemplateField HeaderText="ItemName"><ItemTemplate> <asp:DropDownList id="DropDownList2" tabIndex=16 runat="server" AutoPostBack="True" DataValueField="ItemName" DataTextField="ItemName" ></asp:DropDownList> </ItemTemplate> </asp:TemplateField>  <asp:TemplateField HeaderText="Category"&

how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

how to use nested gridview's rowupdating event

Hi all,            I have a GridView within a GridView. I want o access child gridview's rowupdating event. i want to update row.            this is my GridView's code as follows<asp:GridView ID="grdv1" runat="server" AutoGenerateColumns="false" EmptyDataText="No records found" OnRowDataBound="grdv1_RowDataBound" CellPadding="0" Width="500px" CellSpacing="0" BorderWidth="0"> <Columns> <asp:TemplateField> <ItemTemplate> <table width="100%"> <tr> <td align="center"> <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' CssClass="nbdcontent"></asp:Label> </td> </tr> <tr> <td style="height: 150px"> <asp:GridView ID="grdv2" runat="server" AutoGenerateColumns="False&

Accessing a row's dropdownlist values AFTER the gridview control is in Edit mode

Hello, I have a gridview control. When it goes into Edit mode, there are 3 dropdownlists in one cell that are populated by separate stored procedures during the RowDataBound event. The 1st dropdownlist's value is used as a parameter to determine what the 2nd dropdownlist is populated with. The 2nd dropdownlist's value is used as a parameter to determine what the 3rd dropdownlist is populated with. Everything works fine when the row is first put into Edit mode. While I'm in Edit mode and I change the selection in the 1st dropdownlist, how do I access the control so I can feed this new parameter to the 2nd dropdownlist? I have the first 2 dropdownlists set for AutoPostBack so that the Page_Load event is fired when the user changes a value. I know how to get access to these controls via the FindControl method when the row is being databound but how do I find the control during the Page_Load event? Thanks for any help!!!   Penny  

Gridview RowCommand Event returning null values

HiI'm trying to retreive values entered by users in the textboxes in the footer of the gridview and insert these values into another sql table.My code is as follows :-protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)    {       if(e.CommandName.Equals("addnew"))       {                       TextBox t1 = (TextBox)GridView2.FooterRow.FindControl("tfrm");            string frm = t1.Text;            TextBox t2 = (TextBox)GridView2.FooterRow.FindControl("tsub");            string sub = t2.Text;            string cmd = "insert into suggestions values('" + frm + "','" + sub + "','c','c')";            con.Open();            SqlCommand com = new SqlCommand(cmd,con);            int a = com.ExecuteNonQuery();&n

keep values in textbox in gridview whilst paging

Hi,   I have a gridview in my webpage which has paging enabled. There are around 5 textboxes in a row and when I enter some text and then move to another page and move back to the page I entered the values in, they are not lost. I have enabled the viewstate in the gridview. I have implemented a datatable to my grid which should hold the values in the viewstate. This worked before I added paging. Please can someone offer some advice as to how I can maintain the values in textboxes whilst moving between different pages? I have tried searching it but I can't seem to find any relevant info.   Thank you very much.

gridview values confusion

hi guysi have one page "Search" where the user can search based on the name of the customerI have another page that contains the details for that customermy question is that on the top of the second page i would like to have the name of the customer that the user search for.so the page would look like this                   JOHN JOHNSONDob    .......Tel ........etcwhen i try to create a gridview to bring the value of the name on the top of the page i get confused because the WHERE clause only allows me to select from textboxes included in that page and not on another pagehow can i overcome this?

Build xml file from gridview values on button click

We are looking to add GoogleMaps to our application. With that said we are going to be using the geocoding api to pass in the lat and long values to pin point locations on the the map. Reading thru the documentation we can pass in the values via XML, so we would like to see how we can take the lat and long values from our gridview and pass that to the API if and when somone clicks on the button to show the map.. The process will work like so, you arrive at the search page, you complete a search, in most if not all cases, you will always get multiple results presented in a gridview. If you should to view them all on the map, you click button and it needs to map out each location on the map. So is there anyway to pull from the gridview the lat, long and description to pass into the API?   Any links to sites that i can review would be great. thanks. 

How can I replace values in GridView returned from a Stored Procedure

I am working on creating a stored procedure that will output a pivot table.  In the pivot table will be either the string NULL or a number.  How can I reformat this in ASP.NET so the NULL value becomes a blank cell in the gridview and the number (whatever it is) becomes an 'X' ?

Dashboard Designer: KPI's - Scoring Pattern "Decreasing is Better" returns confusing values

Good day, I started using Sharepoint a few weeks back. I jumped straight into PerformancePoint Services, and have now now gotten the hang of it, r at least I think. Far from mastering anything though. Problem is: I have a table with three fields, namely ProjectName, ProjectBudget and ProjectCost put very simply. Say for example I have these records... ProjectName ProjectBudget ProjectCost Project A 15 000 20 000 Project B 10 000 20 000 Project C 15 000 15 000 Project D 15 000 10 000 Using ProjectBudget as my Target and ProjectCost as my Actual. How can I ensure that Project A and Project B are displayed as off target, while Project C and D are displayed as on target. Lastly, the percentages that are referred to in the "Thresholds" section, what are they referring to? Please let me know, if I need to provide more info. Thank you very much.  

new with regex. returns no values. please help.

I have to pull out the content between(and including) every set of curly braces in a DownloadString. This is one sample that only has one set  of braces.[{"post_id":7046,"post_date":"2010-09-10 09:25:55","title":"Braking News: Keep Your Stopping Power","content":"<p>\r\n<object width=\"400\" height=\"320\" data=\"http:\/\/autonettv.com\/media\/mediaplayer.swf\" type=\"application\/x-shockwave-flash\">\r\n<param name=\"flashvars\" value=\"file=http:\/\/autonettv.com\/media\/BrakeService_Brittani_ChromaKey_Report_v3.flv&amp;image=http:\/\/autonettv.com\/media\/thumbs\/BrakeService_Brittani_ChromaKey_Report_v3.jpg&amp;autostart=false\" \/>\r\n<param name=\"src\" value=\"http:\/\/autonettv.com\/media\/mediaplayer.swf\" \/>\r\n<param name=\"AllowScriptAccess\" value=\"always\" \/>\r\n<\/object>\r\n<br \/><br \/> Richard Petty once told AutoNetTV, &ldquo;You&rsquo;ve gotta have good brakes. If you&rsquo;ve got good brakes you can keep yourself out of a lotta trouble.&rdquo; <br \/><br \/> That&rsquo;s why a regular brake inspection is on every San Francisco car&rsquo;s maintenance schedule. An inspection at <a title=\&

How to Get Values from Current Row of a gridview

hallo all.. how can i access my gridview so that i can get the current row column values..pls help me

Save temporary values in gridview to database

Hi.I have a code here,where it will store temporary data in a gridview from textbox where when the data is stored temporarily in gridview.Alternately,it will be linked to search the word in google.Now i want to save the values in the gridview to database.I m new to asp.net,seeking ideas from all.Any ideas guys?Here is my .aspx code: <body> <div> <table > <tr> <td class="style1"> <asp:Label ID="Label1" runat="server" Text="Caller Info :"></asp:Label> </td> <td style="width: 100px"> <asp:TextBox ID="TxtName" runat="server" class="cls" onekeypress="" ToolTip="Press Enter key for new input"></asp:TextBox> </td> </tr> </table> <asp:Button ID="BtnAddToTable" runat="server" align="right" class="cls" Text="Add" OnClick="BtnAddToTable_Click" /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" > <Columns> <asp:TemplateField HeaderText="Caller Information"> <ItemTemplate> <a onclick='document.getElementById("<%=iframe1.ClientID%>").src = this.href; return false
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend