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

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

Questions with GridView/DetailsView Refresh

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

I have a Gridview that when a record os selected it opens that record in a Detailsviews for Editing, Updating, Inserting and etc.  That is working perfectly but I have two related questions....

1. If I select "New" or "Edit" in the DetailsView I want the cursor to be located in the first field reading for entereing. How can I make this happen?

2. If I update a record selected in the Gridview in the DetailsView, the record is updated in the SQL table but the update is not reflected in the GridView.  Even after refreshing the link the GridView does not display the updated data. How can this be corrected?

All comments appreicated!

View Complete Post

More Related Resource Links

Master-Detail with the GridView, DetailsView and jQuery's ThickBox

One more article about grids from Matt Berseth. This time he shows how to create master-detail with the gridview, detailsview and jQuery's ThickBox. He writes:
So I thought I would check some of this out and along the way rebuild my Master-Detail with the GridView, DetailView and ModalPopup Controls and replace the ModalPopup with jQuery's ThickBox. I found it pretty interesting - read on to see how it went

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">
                <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" 
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <asp:Button ID="AbrirModal" runat="server" Text="->" /> 
                                <asp:PopupControlExtender ID="PopupControlExtender1" runat="server"

avoid gridview refresh



i designed a gridview, page load event i bind some reocrds to the gridview(the gridview is within Updatepanel only.). after that using JS i have modified the rows data. but one time the page hit row_command event at that time all the modified data by JS was reverted and i can see only the row data which was binded at page_load event. but i want to see the JS data alwayas visible even if its hit server side event,how to do that?

change value without refresh gridview


Hi Friends,

I am trying to update my count value in gridview once i have click on my link my count value is updated, i am already do this using javascript and also i hv do this change in database and get the proper responce of that.
But i want to do that without refreshing page or gird my count value is increase which is i had.

Try to find out someting..

If any confusion then ask fill free..

Thanking in advance.


How to Refresh Gridview data from update panel in specified time


hello frnds,

i have some search criteria.

after filling all criteria when i press search button the result arrives in gridview nw when searchbutton pressed after that every 20seconds i want 2 update gridview data which is in update panel

GridView - page refresh



I switched from VWD 2010 express (on Win XP) to VS2010 PRO (on Win 7 PRO). I imported a web application (in development) from VWD to VS. 

Now when I "view in browser" an aspx page with a GridView control everytime I select a record entire page reloads (in Win Xp with VWD it didn't).


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="930px"  
        DataKeyNames="KontaktID" DataSourceID="SqlDataSource1" AllowPaging="True" PageSize="10"  
        AllowSorting="True" onpageindexchanged="GridView1_PageIndexChanged" >
        <AlternatingRowStyle BackColor="#C5C5E2"></AlternatingRowStyle>
        <SelectedRowStyle BackColor="#FFB56A"></SelectedRowStyle>
        <HeaderStyle Height="25px" VerticalAlign="Middle" />
            <asp:CommandField ShowSelectButton="True" SelectText="Izberi" >
                <ItemStyle Width="5%" HorizontalAlign="Center"></ItemStyle>
            <asp:BoundField DataField="ID" HeaderText="id" ReadOnly="T

DetailsView used with GridView


 I want users to select a record in the GridView and then have that record open up in the Detailsview.   How would I go about getting these two tools to communicate? Thanks!

How can I get gridview and detailsview to show up when there are no records.


How can I get gridview and detailsview to show up when there are no records.  I need this for my edit's



Questions for DetailsView



I have created a detailsView control to add/edit/delete profiles on the application which has a field "Country Name". What I would like to do is that, when "insert Template" is selected there is a Dropdown list with list of countries.  But when edit template is selected, there can be two possibilities. If the "type" field from my query string says "a" then I should be able to select any country from the dropdownlist. But if the "type" field says "b" then the dropdownfiled should be disables and should show the original country of the person.

I tried adding a dropdowm list in details view "ItemTemplate", ddCountryList. But now when I try to access it in the code file, it says "ddCountryList" does not exists in current context.

What can be the reason and how can disable and enable a control based on querystring value?

Thank you.

Gridview refresh after edit?



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:


<%@ 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">
    <form id="form1" runat="server">
    <div style="width: 850px; float: left">
        <asp:SqlDataSource ID="SDS_Products" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>

get a correct row index after refresh the gridview table


hi all,

i am facing a problem to get a correct row index after i filter the data in table, it always keep the history row index in the table  before i filter. i had a search button to filter the data in gridview,

below is my coding:


 <asp:Button ID="btn_reissue" runat="server" Text="Reissue" CommandName="reissue"  CommandArgument='<%# CType(Container, GridViewRow).RowIndex %>' OnClientClick="return window.confirm('Are you sure you want to reissue this record?');" Width="65px" />


    Protected Sub grdview_rowcommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gridView1.RowCommand
        Dim cmd As SqlCommand
        If e.CommandName = "reissue" Then
            If Not pUser Is Nothing Then
                pDbUserCon = New SqlConnection(pDbESS)
                pDbUserTrx = pDbUserCon.BeginTransaction()
                    Dim index As Integer = Convert.ToInt32(e.CommandArgument)
                    Dim row As GridViewRow

Find and Set DetailsView Controls In Empty Data Template in Gridview



I would like to find controls in the detailsview control placed in the EmptyData Template of the gridview.   I am trying to create Insert new record for the gridview control.

1. If there are existing records in the table - works fine and sets my two values:
 placed Detailsview and Insert Button in the footer of the gridview.  I needed to set the values of two fields.  When I click on the Insert button it saves new record and sets the field with the value (code attached - works fine).  I also have a popup extender that opens detailsview - this works just fine.

2, If ther are not records in the table - saves record but cannot find and set controls on the detailsview
Same thing setup in the EmptyData Template.  The record is saved but I cannot Find and set the field value on the control.

Here is code:

1.  Link button (on click) in the gridview footer (works fine)

protected void LinkButton1_Click1(object sender, EventArgs e)


        string zupa1;

        zupa1 = ddlSelectEmployee.SelectedValue;





Convert code for GridView to work in DetailsView


Can anyone help me out please ?  I want this code to work in a DetailsView -

protected void gvContacts_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType.Equals(DataControlRowType.DataRow))
            DropDownList ddlGroupName = (DropDownList)e.Row.FindControl("ddlGroupName");
            Label lblGroupName = (Label)e.Row.FindControl("lblGroupName");
            lblGroupName.Text = ddlGroupName.SelectedItem.Text;
            ddlGroupName.Visible = false;

Thank you in advance

Gridview refresh after databound changes


I've been working on a colleagues site, and have been unable to fix a coupld of issues with it.  One of which is a refresh of a Gridview panel.

The page allows a user to navigate a tree structure and then display the permissions on a user selected folder.  Permissions are then added/removed and Saved.

What's not happening is the saved changes aren't being refreshed in the Gridview, also after doing this process once selecting another folder doesn't refresh the Gridview either.

 Below is the sa.aspx file

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sa.aspx.cs" Inherits="sa" Debug="true" %>

<%@ Register Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Import Namespace="System.Web.Services" %>
<%@ Import Namespace="System.Web.Script.Services" %>

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

Drag GridView Row and Drop in DetailsView using jQuery

"Drag & Drop" is a feature that adds more interaction to the UI. When there are too many columns in the GridView, it is essential to provide a DetailsView for the end user to interpret individual rows effectively. This is done often on clicking GridView select button. To give a different and interactive user experience, we can enable end users with options to drag any row from GridView and drop it on DetailsView for detailed display. In this post, I am going to explain with a simple example on how to drag a GridView row and drop it in a DetailsView using jQuery UI's 'Draggable' and 'Droppable' mouse interactions.

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.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.
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