Hi,
please see this example: when the DoSomething button is pressed, ReBind() is called twice. The second time, the RadGrid does not refresh.
Right now, after the button is pressed, the grid displays "loading", but then does not display "finished". How would I get RadGrid to correctly display "loading" and then "finished"?
Thanks,
Donald
please see this example: when the DoSomething button is pressed, ReBind() is called twice. The second time, the RadGrid does not refresh.
public
partial
class
_default : System.Web.UI.Page
{
protected
override
void
OnInit(EventArgs e)
{
if
(!IsPostBack)
{
Session[
"data"
] =
new
List<
string
>() {
"ready"
,
"ready"
};
}
base
.OnInit(e);
}
protected
DataTable GetGridDataTable()
{
List<
string
> data = Session[
"data"
]
as
List<
string
>;
DataTable dataTable =
new
DataTable();
dataTable.Columns.Add(
"Name"
);
foreach
(
string
s
in
data)
{
dataTable.Rows.Add(s);
}
return
dataTable;
}
protected
void
RadGrid1_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetGridDataTable();
}
protected
void
Button_Click(
object
sender, EventArgs e)
{
Session[
"data"
] =
new
List<
string
>() {
"loading"
,
"loading"
};
RadGrid1.Rebind();
System.Threading.Thread.Sleep(2000);
Session[
"data"
] =
new
List<
string
>() {
"finished"
,
"finished"
};
RadGrid1.Rebind();
}
}
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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
id
=
"Head1"
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
div
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
Width
=
"400px"
>
<
MasterTableView
DataKeyNames
=
"Name"
Name
=
"ParentTable"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Name"
UniqueName
=
"Name"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:Button
Text
=
"Do something"
OnClick
=
"Button_Click"
runat
=
"server"
/>
</
div
>
</
form
>
</
body
>
</
html
>
Right now, after the button is pressed, the grid displays "loading", but then does not display "finished". How would I get RadGrid to correctly display "loading" and then "finished"?
Thanks,
Donald