2
Answers

Error while populating datagrid using ASync Call

Ashish

Ashish

16y
10.9k
1

Hi All,

I am using Async call to populate datagrid by following code.

This code I have written in a class which inherit in other class. This class has a virtual method which is overridden in derived class.

Problem I am facing is, datagrid is populated and displayed sometimes and not every time I load the page.I already checked the rowcount in table that I am assigning to grid. I am getting the proper row count.

I have declaired a delegate and using BegingInvoke and EndEnvoke method for it.

FYI, flgrd is an object of delegate.

 

private void CallAsyncMethod()

{

flgrd = new FillGrid(processData);

flgrd.BeginInvoke(new AsyncCallback(this.callAsyncResultMethod), flgrd);

}

private void callAsyncResultMethod(IAsyncResult ar)

{

flgrd = ((FillGrid)(ar.AsyncState));

flgrd.EndInvoke(ar);

}

public virtual void GetData()

{

// User will write code in derived class to populate datagrid.

}

private void processData()

{

this.GetData();

}

Answers (2)