Hi all
I need help in griview and ajax question, lets say I have a table wich contains about 100 000 records and I need load them into gridview but it takes too long, how can I load it row by row lets say first row is loaded and others show some "Loading... " message ans so on.
Thanks in advance.
One thing more, may be somebody knows how to hide an update panel when update progress is firing?Hi,
Please refer to this sample:
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!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>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </ContentTemplate> </asp:UpdatePanel> <asp:Button OnClientClick="" ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass Default2 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { Button1.OnClientClick ="document.getElementById('UpdatePanel1').style.display='none';"; BindData(); }static DataTable source;protected void BindData() {if (source ==null) { source =new DataTable(); source.Columns.Add("column 1"); source.Columns.Add("column 2"); } DataRow row = source.NewRow();// you can use datareader to get data from database here row[0] = DateTime.Now.ToString(); row[1] = DateTime.Now.ToString(); source.Rows.Add(row); GridView1.DataSource = source; GridView1.DataBind(); }protected void Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); }}
Please note here use nested UpdatePanel to achieve your second requirement of hide a panel.
Another thing you must pay attenation to is that such a function will cause a higher network traffic.
Hope this helps.
1 comment:
Localizing in DataGridView in C#.NET
Post a Comment