RadGrid Client side binding without service

6 posts, 0 answers
  1. Ruchi
    Ruchi avatar
    54 posts
    Member since:
    Apr 2012

    Posted 11 Feb 2015 Link to this post

    Hello Team,

    I am working on one web application, in which we need to bind radgrid client side, we have not created any data service.

    there in one aspx page inside application, that returns data in one json object, i tried the same as below:
    <ClientSettings>
                <DataBinding Location="https://locallhost/LoadWidgetsAsync.aspx" ResponseType="JSON">
                    <DataService TableName="Table1" />
                </DataBinding>
     </ClientSettings>


    It is not showing data in grid, can anyone help me out with binding radgrid without service?

    Thanks in advance,
    Ruchi Patel
  2. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 11 Feb 2015 in reply to Ruchi Link to this post

    Hi
    Can u share your Issue Snapshots or post your code.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ruchi
    Ruchi avatar
    54 posts
    Member since:
    Apr 2012

    Posted 11 Feb 2015 Link to this post

    Hello Jaya,

    Please find code below:

    Rad grid as below:
    <telerik:RadGrid ID="rgGrid" runat="server" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="true"
            AllowFilteringByColumn="true" PageSize="5">
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn DataField="LogDate" HeaderText="Log Date" UniqueName="LogDate" DataType="System.String">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="IPAddress" HeaderText="IP Address" SortExpression="IPAddress" UniqueName="IPAddress" DataType="System.String">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Result" HeaderText="Result" SortExpression="Result" UniqueName="Result" DataType="System.String">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <DataBinding Location="https://localhost/LoadWidgetsAsync.aspx" ResponseType="JSON">
                    <DataService TableName="Table1" />
                </DataBinding>
            </ClientSettings>
        </telerik:RadGrid>

    Page used to get data as below:
    DataTable dt = new DataTable();
    DatabaseTools dbTools = new DatabaseTools(SQLConnection);
    string queryString = string.Format("SELECT LogDate, IPAddress, (CASE WHEN Result = 1 THEN 'Success' ELSE 'Fail' END) AS Result FROM LogDetails WHERE UserName = '{0}' ORDER BY LogDate DESC", (Context.User.Identity).Name);
    dt = dbTools.GetDataTable(queryString);          
    dbTools.CloseConnection();
    dbTools.Dispose();
     Response.Clear();
     Response.ContentType = "application/json; charset=utf-8";        
     Response.Write(JsonConvert.SerializeObject(dt));
     Response.End();

    Thanks and Regards,
    Ruchi Patel
  5. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 11 Feb 2015 in reply to Ruchi Link to this post

    hi

     DatabaseTools dbTools = new DatabaseTools(SQLConnection);

    This is Third party dll? how can i use this?  what is ur issue?
  6. Jaya
    Jaya avatar
    81 posts
    Member since:
    Mar 2011

    Posted 11 Feb 2015 in reply to Ruchi Link to this post

    hi
    refer this url

    http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/programmatic/defaultcs.aspx
  7. Ruchi
    Ruchi avatar
    54 posts
    Member since:
    Apr 2012

    Posted 11 Feb 2015 Link to this post

    Hello, Sorry it was not a third party tool.

    Its just a class that is used for sql connection.

    you can remove that line and replace "dt = dbTools.GetDataTable(queryString);   " with below code:
    SqlCommand command = new SqlCommand(queryString, connection);           
                   connection.Open();
                   SqlDataReader reader = command.ExecuteReader();
                   dt.Load(reader);
                   reader.Close();
                   connection.Close();


    For connection variable, you need to give SQLConnection.

    Thanks and Regards,
    Ruchi Patel
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017