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

ObjectDataSource Not Updating Grid

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fletch
Top achievements
Rank 1
Fletch asked on 26 Jul 2011, 09:21 AM
Hello everyone

I have a Telerik RadGrid on a page that uses an asp ObjectDataSource.  This is a search page, and the user selects some options from drop down lists etc and then clicks a Search button.  The ObjectDataSource uses a SelectMethod to retrieve the data from the database based on the parameters.  I have set a breakpoint here and the ObjectDataSource returns the correct dataset.  However the grid does not update.  I have set AllowPaging = true, and if I change the page size, the grid updates with the correct data.

Many thanks for your help

Grid
<telerik:RadGrid ID="alarms" runat="server" CssClass="gridview" AllowAutomaticUpdates="true"
        AutoGenerateColumns="false" OnItemDataBound="AlarmDataBound" AllowPaging="true" AllowSorting="true"
        AllowMultiRowSelection="true" PagerStyle-Mode="NextPrevAndNumeric" PagerStyle-AlwaysVisible="true">
    <MasterTableView>
        <Columns>
            <Columns removed>
        </Columns>
    </MasterTableView>
    <ClientSettings EnableRowHoverStyle="true">
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
    <SelectedItemStyle CssClass="selected" />
    <AlternatingItemStyle CssClass="even" />
</telerik:RadGrid>

DataSource
<asp:ObjectDataSource ID="alarmData" runat="server"
     SelectMethod="GetAlarmData" TypeName="******.AlarmManagement" >
</asp:ObjectDataSource>

DataSource SelectMethod
public DataSet GetAlarmData(string dummy)
{
    using (SqlConnection connection = new SqlConnection(connString.ConnectionString))
    {
        try
        {
            connection.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            DataSet ds = new DataSet();
            // Get the data based on search criteria
              
            da.Fill(ds);
            return ds;
        }
        catch (SqlException ex)
        {
            // Log the error
            return null;
        }
        finally
        {
            connection.Close();
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Fletch
Top achievements
Rank 1
answered on 26 Jul 2011, 09:47 AM
I was being stupid - fixed now
Tags
Grid
Asked by
Fletch
Top achievements
Rank 1
Answers by
Fletch
Top achievements
Rank 1
Share this question
or