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


Top 5 Contributors of the Month
abhays
Clintonzz
cathyhill345
arronlee
mattyclown
Post New Web Links

Gridview refresh after edit?

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net
 

Hi,

this one is cracking my brain.
I have a gridview and a formview on one page.
When a row of the gridview is selected, the details will load in the formview.
When i edit the details (f.e. change a name) in that formview and save them, the gridview will just show the old data (=old name).

I have to reload/F5 the page to see the changes in the gridview.
Why isn't the GV updated when i do a databind() in the onclick-event of the update-button in the edittemplate of the formview?

This example is using the northwind database:

ASPX:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="width: 850px; float: left">
        <asp:SqlDataSource ID="SDS_Products" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>


View Complete Post


More Related Resource Links

Inplace Edit in GridView

  
In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

Edit GridView Individual Cells in ASP.NET

  
The ASP.NET GridView allows for a row of data to be edited by setting the EditIndex property of the GridView, placing the entire row in edit mode.

You may not want the entire row in edit mode if you are using DropDownList controls for several columns in the EditItemTemplate. If each DropDownList has many options then loading them all at once may result in a sluggish page. Also, if your data structure is more like a 2 dimensional array rather than a set of rows, you may want to edit each cell individually.

Here I will demonstrate how to achieve this and also how to deal with event validation without disabling it.

ASP.Net Gridview Edit Update Cancel Commands

  
In ASP.Net 2.0, GridView Control also provides the functionality to edit and update the data retrieved from the database using CommandField template. You can cancel the action using Cancel Command of the CommandField. GridView consists of events that can be used to perform the actions like edit, update and cancel upon the Data items displayed in the ASP.Net GridView Data Control.

Edit Individual GridView Cells in ASP.NET

  
The ASP.NET GridView allows for a row of data to be edited by setting the EditIndex property of the GridView, placing the entire row in edit mode.

You may not want the entire row in edit mode if you are using DropDownList controls for several columns in the EditItemTemplate. If each DropDownList has many options, then loading them all at once may result in a sluggish page. Also, if your data structure is more like a 2 dimensional array rather than a set of rows, you may want to edit each cell individually.

ASP.NET GridView - edit records using JQuery Dialog

  
There are many ways in which you could modify modular data in Grid View:
1. Inline by making rows editable when u click on Edit
2. By using separate pages for Edit
3. By using popups/dialogs for adding/editing

Gridview Edit on Searching of Record

  

using Asp.net c#

sql server

i am searching a record from my database and displaying it in gridview now i want the comments should be updated as per the record which is being searched

For E.g if record No.3 is searched then only i can update record no.3 and i don't want rest of data to be shown


now what is happening when i click on edit my whole table is being displayed

this is bcuz i made one method gridfill() which i m calling everytime if i m doing grid row editing,row cancelling and row updating

how i can resolve this thing

my code

 protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView2.EditIndex = e.NewEditIndex;
        gridfill();

    }

 protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string id = GridView2.Rows[e.RowIndex].Cells[0].Text;
        TextBox t;
        t = (TextBox)GridView2.Rows[e.RowIndex].Cells[2].Controls[0];
        string query = "update user1 set comments=@comments where id=@id";
        SqlConnection con = new SqlConnection(connstr);
        con.Open();
        SqlCommand cmd = new SqlCommand(query, con);
        cmd.Parameters.AddWithV

How to let user edit selected gridview columns, not entire row

  

Hello!-

I've got a gridview I would like to let the user edit a couple of columns.  Seems like everything I'm coming across so far makes the entire row editable.  

Hopefully the solution isn't too complicated.  Can someone point me in the right direction?

 


LINQ with GridView and edit fields

  

My project includes a grid view which displays information of inventory items (Assets), data is quried from AssetTable. The GridView has a command field to allow editing, below is a description of the tables and how data is displayed

Tables

BuildingTable: (BuildingID, BuildingName)

AssetTable: (BuildingID,..,....,....)

 

ItemTemplate: Using a LINQ query I join the two table and displays in a label control a string which includes BuildingID and BuildingName (5 North Building)

 EditItemTemplate: Using a LINQ query I populate a DropDownList with strings of BuildingID and BuildingName same as above.
 
Here  issue which I need to resolve:
1.  ItemTemplate display the correct information (BuildingID BuildingName) but when I switch to EditItemTemplate the pair that is 
displayed is the first one on the list, how do I make is scroll to the item which was displayed in the label ?
 
 
 
<asp:CommandField ShowEditButton="True" >
                    <ControlStyle Wi

Add, Edit, update, Delete gridview

  
The article Add, Edit, update, Delete gridview was added by anjankant on Friday, July 09, 2010.

Thousandas operation we can do on Gridview control. Here I as explaining how we can add new recored and edit of existing record and delete a record in Gridview. Step1 : You can add this gridview in your aspx form. Here some events of Gridview are fired

determine the best way to refresh a gridview when textchanged event occurs

  

Good afternoon.

I have the following gridview inside an updatepanel that makes the bind from a datatable:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Button ID="ButtonAdd" runat="server" OnClick="ButtonAdd_Click" Text="Novo Artigo" />
                <asp:GridView ID="Dados" runat="server" AutoGenerateColumns="False" 
                    CssClass="Grid" Width="100%" CellPadding="4" ForeColor="#333333" 
                    GridLines="None">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                    <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Button ID="AbrirModal" runat="server" Text="->" /> 
                                <asp:PopupControlExtender ID="PopupControlExtender1" runat="server"
                                TargetControlID="AbrirModal"
                                PopupControlID="PanelArtigos"
                                >
                                &l

jquery datepicker not popping up in Gridview Edit Template textbox

  

I have a gridview that I can't for the life of me get the datepicker calender to pop up for.  I've been using the datepicker for months very successfully for a variety of textboxes on the page and inside of formviews but this is the first time I've tried using with gridview.  I didn't expect any issues however can't seem to find anything to work.  I have searched the forums for 2 days and attempted any suggestions found within the solutions to no avail.  I've tried using the CSS to link the datepicker but everything stopped working when I changed the code and my page which uses a css style already got all distorted looking.  Please help!

Here is my gridview (only included a part b/c it is large and am only having problem with the datepicker for the date completed text box)

<asp:GridView ID="GridViewCompleted" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
        BorderWidth="3px" CellPadding="4" DataKeyNames="job_id" DataSourceID="SourceJobProjectCompleted"
        ForeColor="Black" CellSpacing="2">
<Columns>

Multiple update statements per row in Gridview Edit

  

I want to set up a gridview that will display data like this

WeekEndingDate Project Category Sun Mon Tues Wed Thu Fri Sat
8/14/2010      proj1   test     2   1   2    3   2   1   0
8/21/2010      proj1   test     0   2   2    2   2   1   0
8/28/2010      proj1   test     0   1  

Edit gridview record on 2 rows

  

Hi,

Is that possible to edit a record within a gridview on 2 rows to make it look better when editing?

Like I have 8 columns in my gridview.

I wish to have 4 columns on row one and the 4 remaining columns on row 2.

Thanks!


Value into Textbox of GridView Edit

  
Hi there, I am not sure this can be done, and if not I am looking for an alternative. Before I start I am using VB.Net and ASP.Net.What I would like to do, is when the edit button is pressed on a Gridview row, I want the TextBox under the ClockOut column, to automatically have the selected value of a dropdown list at the top of the page. Basically so a list of users times will come up in the grid view, and as a fast way to insert a clock out time, the user will have to change the drop down list at the top of the ASP.Net page to the clock out time they want, then when pressing Edit on the row, the time from the Dropdown list will be in the ClockOut textbox, and pressing update will post this. Any help will be great! Thanks, Hope it can be done.
Categories: 
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