RadButton Quest!!

2 posts, 0 answers
  1. Francisco
    Francisco avatar
    1 posts
    Member since:
    Sep 2013

    Posted 26 Sep 2013 Link to this post

    I am new in the asp.net code and i need generate a report in a gridview with objectdatasource,  when i click a button and the parameters of 4 textbox add to query
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Sep 2013 Link to this post

    Hi Francisco,

    Please have a look into the full code that I tried to populate RadGrid using ObjectDataSource.

    <telerik:RadTextBox ID="RadTextBox1" runat="server">
    <telerik:RadButton ID="RadButton1" runat="server" Text="Generate Gird" OnClick="RadButton1_Click">
    <telerik:RadGrid ID="RadGrid1" AllowPaging="true" AllowSorting="true" runat="server"
        AllowFilteringByColumn="true" Width="100%">
        <PagerStyle AlwaysVisible="true"></PagerStyle>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="Class1" OnSelecting="ObjectDataSource1_Selecting">
            <asp:Parameter Name="textvalue" Type="String" />

    protected void RadButton1_Click(object sender, EventArgs e)
        RadGrid1.DataSourceID = "ObjectDataSource1";
        ObjectDataSource1.SelectMethod = "GetData";
    protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        //passing the parameter value from code
        e.InputParameters["textvalue"] = RadTextBox1.Text;
    Code inside App_Code:
    public class Class1
        public DataTable GetData(string textvalue)
            String connectionstring = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
            SqlConnection sqlconn = new SqlConnection(connectionstring);
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand("SELECT text from Details WHERE id LIKE '" + textvalue + "%'", sqlconn);
            DataTable data = new DataTable();
                return data;

Back to Top