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

Grid disappearing after Postback

1 Answer 348 Views
Grid
This is a migrated thread and some comments may be shown as answers.
THADDEUS
Top achievements
Rank 1
THADDEUS asked on 17 Aug 2016, 07:46 PM

I am using a grid with a combobox and a button to save the checked values from the Grid..

When I click the save button the Grid no longer shows up after post back.

I am using the [radgridHardware_NeedDataSource[ and the functionality was working fine when I used the AutoGenerateColumns=true, but once I changed to use the GridBoundColumn the Grid does not work....  

I have tried all the suggestions on a google search (please see below)   Any help would be really appreciated

 

radgridHardware.DataSource = Nothing

radgridHardware.DataBind()

radgridHardware.MasterTableView.SortExpressions.Clear()

radgridHardware.MasterTableView.GroupByExpressions.Clear()

radgridHardware.MasterTableView.Rebind()

radgridHardware.Rebind()

<div id="leftPanel">
<telerik:RadGrid ID="radgridHardware" runat="server" AllowMultiRowSelection="true"
AllowSorting="True" GridLines="None" AutoGenerateColumns="false"
AllowPaging="True" Skin="Sunset"
PageSize="20">
<MasterTableView>
<Columns>
<telerik:GridClientSelectColumn UniqueName="hardwareSelectColumn" HeaderText="Assign"></telerik:GridClientSelectColumn>
<telerik:GridBoundColumn DataField="RawID" Visible="true" HeaderText="ID" UniqueName="RawID"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Vendor" Visible="true" HeaderText="Vendor" UniqueName="Vendor"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Model" Visible="true" HeaderText="Model" UniqueName="Model"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Product" Visible="true" HeaderText="Product" UniqueName="Product"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<PagerStyle Mode="NumericPages"></PagerStyle>
<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="True"></Selecting>
</ClientSettings>
</telerik:RadGrid>
</div>

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 22 Aug 2016, 11:20 AM
Hi,

I examined the provided code and noticed that you are using DataBind() to bind the grid. Note that this method is used only for simple data binding. As the name implies this type of binding is suitable only for the most simple scenarios.

It is recommended to use the NeedDataSource event to provide data for RadGrid. The grid will raise the event automatically when it needs to retrieve its data. Thus, you would not need to manually provide the data.

Check out the following resources that illustrate how you can bind the grid via NeedDataSource. Give the approach a try and see how it works for you.




Regards,
Viktor Tachev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
THADDEUS
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or