This is a migrated thread and some comments may be shown as answers.

Refresh Grid

3 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vladimir
Top achievements
Rank 1
Vladimir asked on 20 Dec 2011, 01:58 PM
Hi
I have grid control on my page

<

 

 

Rad:RadGrid Width="100%" Height="100%" EnableAJAX="true" ID="grdDispatchedStaff" style="border:0;" runat="server" AllowPaging="False" AllowSorting="True"

 

 

 

AllowMultiRowSelection="false" AutoGenerateColumns="false"

 

 

 

OnNeedDataSource ="GridDispatchedStaffNeedDataSource" >

 

 

 

<MasterTableView DataKeyNames="DispatchAssignmentGUID" ClientDataKeyNames="DispatchAssignmentGUID" AllowNaturalSort="false" TableLayout="Fixed" >

 

 

 

<HeaderStyle Height="18px" Font-Names="Tahoma" Font-Size="7pt" Font-Bold="true"/>

 

 

 

<ItemStyle CssClass="RowModified" />

 

 

 

<AlternatingItemStyle CssClass="RowModified" />

 

 

 

<Columns>

 

 

 

<Rad:GridBoundColumn UniqueName="DispatchAssignmentGUID" SortExpression="DispatchAssignmentGUID" HeaderText="DispatchAssignmentGUID" DataField="DispatchAssignmentGUID" Visible="false" />

 

 

 

<Rad:GridBoundColumn UniqueName="FullName" SortExpression="FullName" HeaderStyle-Width="8%" HeaderText="Name" DataField="FullName" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="RadioID" SortExpression="RadioID" HeaderStyle-Width="8%" HeaderText="Radio ID" DataField="RadioID" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="CallSign" SortExpression="CallSign" HeaderStyle-Width="8%" HeaderText="Call Sign" DataField="CallSign" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="ReferenceID" SortExpression="ReferenceID" HeaderStyle-Width="8%" HeaderText="Ref. ID" DataField="ReferenceID" DataFormatString="{0:d}"/>

 

 

 

<Rad:GridBoundColumn UniqueName="DispatchRole" SortExpression="DispatchRole" HeaderStyle-Width="7%" HeaderText="Role" DataField="DispatchRole" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="DispatchTime" SortExpression="DispatchTime" HeaderStyle-Width="11%" HeaderText="Dispatch Time" DataField="DispatchTime" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="ETA" SortExpression="ETA" HeaderStyle-Width="11%" HeaderText="ETA" DataField="ETA" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="ArrivalTime" SortExpression="ArrivalTime" HeaderStyle-Width="11%" HeaderText="Arrival Time" DataField="ArrivalTime" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="ArrivalCode" SortExpression="ArrivalCode" HeaderStyle-Width="9%" HeaderText="Arrival Code" DataField="ArrivalCode" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="ClearTime" SortExpression="ClearTime" HeaderStyle-Width="11%" HeaderText="Clear Time" DataField="ClearTime" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

<Rad:GridBoundColumn UniqueName="ClearCode" SortExpression="ClearCode" HeaderStyle-Width="8%" HeaderText="Clear Code" DataField="ClearCode" DataFormatString="<nobr>{0}&nbsp;</nobr>"/>

 

 

 

</Columns>

 

 

 

</MasterTableView>

 

 

 

<ClientSettings AllowDragToGroup="False">

 

 

 

<Resizing AllowColumnResize="True" EnableRealTimeResize="true" AllowResizeToFit="true"></Resizing>

 

 

 

<Selecting AllowRowSelect="true" />

 

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="100%"></Scrolling>

 

 

 

<ClientEvents OnRowContextMenu="RowContextMenu" OnRowDblClick="GridDblClick" OnRowClick="GridRowClick"></ClientEvents>

 

 

 

</ClientSettings>

 

</

 

 

Rad:RadGrid>

 


and event handler in code behind

 

 

protected void GridDispatchedStaffNeedDataSource(object sender, GridNeedDataSourceEventArgs e)

 

{

 

 

this.LoadGrid();

 

}


where

 

 

private void LoadGrid()

 

{

 

 

this.grdDispatchedStaff.DataSource = this.DataSource.DispatchAssignment;

 

}


this.DataSource is using DataSet from Session.

I have updated DataSet by adding another row and want to Rebuind Grid. The doc says I can't user bind or rebind with OnNeedDataSource. How can I refresh Grid on the page if data sourcer was changed.
Thanks.
Vladimir



3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Dec 2011, 02:50 PM
Hello,

You can call Rebind() method wherever you need to refresh the RadGrid. NeedDataSource event will fire when a call to the grid's Rebind method takes place.

-Shinu.
0
Vladimir
Top achievements
Rank 1
answered on 20 Dec 2011, 03:10 PM
Hi Shinu
Thanks for the answer, but I alredy tried and it does not refres the grid. What's wrong?
Vladimir
0
Vladimir
Top achievements
Rank 1
answered on 20 Dec 2011, 07:10 PM
I got the solution
add

<

 

 

Rad:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">

 

 

 

<AjaxSettings>

 

 

 

<Rad:AjaxSetting AjaxControlID ="RadAjaxManager1">

 

 

 

<UpdatedControls>

 

 

 

<Rad:AjaxUpdatedControl ControlID="grdDispatchedStaff" />

 

 

 

</UpdatedControls>

 

 

 

</Rad:AjaxSetting>

 

 

 

</AjaxSettings>

 

</

 

 

Rad:RadAjaxManagerProxy>
and it works and grid gets updated
Thanks
Vladimir

 

Tags
Grid
Asked by
Vladimir
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Vladimir
Top achievements
Rank 1
Share this question
or