Hi,
I am new to infragistics. I have used the ultrawebgrid and have set LoadOnDemand="xml", Browser = BrowserLevel.Xml, LoadOnDemand.Xml, LoadOnDemandType = XmlLoadOnDemandType.Accumulative. By default i am setting the rows = 30. I have noticed that every time i scroll down,using AJAX request it get the data from the server. But the only problem is that it fetches all the record every time an AJAX request is done. Is there a way for every AJAX request is done, only fetch the next 30 rows and so on.. Can someone pls help me out?
Thanks
Rajagopalan.
Hi Rajagopalan,
Two help topics cover this scenario:
http://help.infragistics.com/NetAdvantage/ASPNET/2010.3/CLR4.0?page=WebGrid_Partial_Data_Binding.html.
and
http://help.infragistics.com/NetAdvantage/ASPNET/2010.3/CLR4.0?page=WebGrid_Using_a_Data_Window_in_an_XMLHTTP_Enabled_Application.html.
Hi Matthew,
Sorry for the late reply. I was on a week leave. The articles that i sent was very useful. I am able to implement it successfully. But there is a problem that i face, I have a table that has 186871 records, but when i scroll to the last page, the total no of records that it shows is 54229 record only instead of 186871 records. Is there a limit to no of records that will get bind using Partial Bind?
Pls find the code below
int currentRowCount;
int maxRange;
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnInit(EventArgs e)
this.UltraWebGrid1.Browser = BrowserLevel.Xml;
this.UltraWebGrid1.DisplayLayout.LoadOnDemand = LoadOnDemand.Xml;
this.UltraWebGrid1.DisplayLayout.XmlLoadOnDemandType = XmlLoadOnDemandType.Virtual;
this.UltraWebGrid1.DisplayLayout.RowsRange = 300;
this.UltraWebGrid1.InitializeDataSource +=new InitializeDataSourceEventHandler(UltraWebGrid1_InitializeDataSource);
base.OnInit(e);
void UltraWebGrid1_InitializeDataSource(object sender, UltraGridEventArgs e)
DataSourceEventArgs arg = (DataSourceEventArgs)e;
arg.EnablePartialDataBinding = true;
/* Store information if sorting is enabled */
string column = Session["sortedColumn"] != null ? (string)Session["sortedColumn"] : "modifieddate";
string sortDirection = Session["sortIndicator"] != null ? (string)Session["sortIndicator"] : "desc";
// Connect to SQL Northwind database
SqlConnection con = new SqlConnection(@"data source=172.16.10.200\SqlExpress;User ID=rajagopal;password=rajagopal;");
// Get total data count
SqlCommand countComm = new SqlCommand("SELECT COUNT(*) FROM [wms_activityhistory]", con);
con.Open();
int count = Convert.ToInt32(countComm.ExecuteScalar());
con.Close();
// Set total data count so grid will know to request more rows when scrolled
//arg.CompleteRowCount = arg.CurrentRowCount + arg.DataPortionSize + 1;
arg.CompleteRowCount = count;
currentRowCount = arg.CurrentRowCount;
maxRange = arg.CurrentRowCount + arg.DataPortionSize;
GetPartialData(column, sortDirection, currentRowCount, maxRange);
Label1.Text = arg.CompleteRowCount.ToString();
private void GetPartialData(string column, string sortDirection, int currentRowCount, int maxRange)
// Get data between current row and row range provided by event args
SqlCommand comm = new SqlCommand(@"SELECT The_Row_Number, [orderid]
,[task]
,[modifiedby]
,[modifieddate]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY " + column + " " + sortDirection + @") AS The_Row_Number
,[orderid]
FROM [wms_activityhistory]
) AS Row_Number_Added
WHERE
The_Row_Number Between " + currentRowCount + " AND " + maxRange, con);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataTable dt = new DataTable();
da.Fill(dt);
// Set requested data for grid
this.UltraWebGrid1.DataSource = dt;
When i execute the above sql query in DB, i am able to get the record above 54229. In the grid the records above 54229 are getting binded to the grid but it's not displaying the records. Is there a solution for it?
Thanks,
S.Rajagopalan.