Grid disappearing after Postback

2 posts, 0 answers
  1. THADDEUS
    THADDEUS avatar
    4 posts
    Member since:
    Apr 2016

    Posted 17 Aug Link to this post

    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>

     

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 22 Aug Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top