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

[Solved] Radcombobox SelectedIndexChanged problem filter by radgrid

3 Answers 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shanker bangari
Top achievements
Rank 1
shanker bangari asked on 02 Mar 2010, 09:21 AM
Hi

I got  row edit and cancel .But I Am click Add new record that radgrid is clear in first time than again am select combo box value the new records display.why first it,s clear how to solve that this. my code id below when ever am click add new record the radgrid is clears how to solve that .

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection con = new SqlConnection("Data Source=SAMA\\SQLEXPRESS;Initial Catalog=pinfo;Integrated Security=True");
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select * from sch_view_class_lookup",con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            RadComboBox1.DataSource = ds;
            RadComboBox1.DataTextField = "class";
            RadComboBox1.DataValueField="class_id";
            RadComboBox1.DataBind();
        }
    }
    protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
    {
        getdata();
    }
    protected void RadGrid1_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e)
    {

    }
    protected void RadComboBox1_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        getdata();
    }
    public void getdata()
    {
        SqlConnection con = new SqlConnection("Data Source=SAMA\\SQLEXPRESS;Initial Catalog=pinfo;Integrated Security=True");
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter("select * from sch_view_sch_student_remark_list where class_id='" + RadComboBox1.SelectedValue + "'", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        RadGrid1.DataSource = ds;
        RadGrid1.DataBind();
    }
    protected void RadGrid1_EditCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        getdata();
    }

    protected void RadGrid1_CancelCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        getdata();
    }
 
thanks and regards
shanker.B

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 02 Mar 2010, 09:47 AM
Hello Shanker,

Please, note that insert/update/delete operations are not supported with simple data binding calling DataBind() method. To achieve the desired functionality I would suggest you to bind the grid trough the NeedDataSource event. Then you can handle the insert operation to work properly as shown here.

I hope this helps.

Kind regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
shanker bangari
Top achievements
Rank 1
answered on 02 Mar 2010, 10:12 AM
Hi,

Thank you for your response .It's ok fine, But I am radgrid binding in combobox selected index changed  event .

 I know  u r refer code .this is my code But I Am click Add new record that radgrid is clear in first time than again am select combo box value the new records display.why first it,s clear how to solve THIS. 

 protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
    {
        getdata();
    }
    protected void RadGrid1_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e)
    {

    }
    protected void RadComboBox1_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        getdata();
    }
    public void getdata()
    {
        SqlConnection con = new SqlConnection("Data Source=SAMA\\SQLEXPRESS;Initial Catalog=pinfo;Integrated Security=True;Min Pool Size=5;Max Pool Size=60;Connect Timeout=60;");
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter("select * from sch_view_sch_student_remark_list where class_id='" + RadComboBox1.SelectedValue + "'", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        RadGrid1.DataSource = ds;
       
        con.Close();
    }
    protected void RadGrid1_EditCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
         
        getdata();
    }

    protected void RadGrid1_CancelCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        getdata();
    }
THANKS AND REGARDS 
shanker.B

0
Pavlina
Telerik team
answered on 02 Mar 2010, 11:39 AM
Hello Shanker,

I am not sure what exactly you need to achieve. Could you please provide a little bit more information about your scenario? Once I have a better view over your setup I will do my best to help.
 
Additionally, I suggest you review the following online examples which are related to this subject:
Load on Demand modes
Load on Demand Grid in Combobox
Combo in Grid

Greetings,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
shanker bangari
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
shanker bangari
Top achievements
Rank 1
Share this question
or