You must Sign In to post a response.
  • Category: .NET

    Add data in gridview without refresh

    hi all

    i am displaying data in the gridview from database on map click.

    ie on map click iam getting x,y values . i am passing these values in to database to get the data.

    If i am clicking second time on the map the it has to display the record along with the first record

    ie first time if i click on the map the record displays as

    1 x

    if i click again on the map, the it has to display fisrt record and the second record as

    1 x

    2 y
    !
    !
    !
    !
    !
    !
    and so on

    but for me page is refreshing every time and displaying only one record, i am not able to view the previous records

    please tell me the code for this
  • #764298
    To avoid page-postback you can Update panel and you can keep dataset copy with you for next update, so that you can add new record each time in it.
    Above is the concept only, but what you about your code ? can you share code with us so that we can help you better to resolve problem

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764299
    Hi,

    In this case you can store your records into session object and add records into that session whenever you are fetching it from database, and use that session and get your records and use in your case.


    DataSet ds=//get data from database;

    if(Session["Data"]!=null)
    //add records into session
    else
    //create temp columns and store the initial data into session object.


    Hope this will helpful to you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #764301
    Hai Rishe,
    You can use the Script Manager control in your form and keep the GridView inside UpdatePanel contorl.
    by this way, when adding the data to gridview, it will not do the postback.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #764315
    hi naveen,

    Thanks for ur response.
    Please send me the code .
    How to create temp columns and store the initial data into session object.

  • #764319
    Use below sample and reuse the same,

    if(Session["Data"]!=null)
    {
    DataTable dt1= Session["Data"] as DataTable;
    DataTable dt2=//temp data;
    dt1.Merge(dt2);
    Session["Data"]=dt1;
    }
    else
    {
    DataTable dt1=new DataTable();
    dt1.Columns.Add("col1");
    dt1.Columns.Add("col2");
    DataRow dr=dt1.NewRow();
    dr[0]="data1";
    dr[1]="data2";
    dt1.Rows.Add(dr);
    Session["Data"]=dt1;
    }

    Above code will guide you how to reuse the session and how to store the initial data into session etc...
    You need to workout more by prepare code by your self and debug the code logic and check whether it meets your requirement or not.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments