RadListBox not setting multiple values

3 posts, 0 answers
  1. satya chaluvadi
    satya chaluvadi avatar
    4 posts
    Member since:
    Jul 2009

    Posted 04 May 2010 Link to this post

    Hi,

        I am using RadListBox in one of our page,  I can able to retrieve multiple selection info and save it to destination place, and when users open the form again, I need to get previous selections(multiple values) and set it to RadListBox, it only showing last value not other selection.   I am calling the following method for setting values.

     

    private

     

    void setRadListBoxSelection(Telerik.Web.UI.RadListBox ctl, string val)

     

    {

     

    string[] selArr = val.Split('@');

     

     

    foreach (string word in selArr)

     

    {

    ctl.SelectedValue = word;

     

    // ctl.SelectedItem.Value = word;

     

     

     

    }

     

    }

    do you have any suggestions for fixing the above issue.

    Satya

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 06 May 2010 Link to this post

    Hello Satya,

    First, you should set SelectionMode property of the listbox to "Multiple", then use the following javascript:

    ctl.findItemByValue(word).set_selected(true);


    Greetings,
    Yana
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 04 Nov 2011 Link to this post

    hi yana.......help me
     i am velmurugan
    now  i am using radlistbox for selecting multiple items and sould be stored in database  with same id
    001 PERIOD1
    001 PERIOD2
    001 PERIOD3
    001 PERIOD4

    And also when display the stored datas in radgrid like PERIOD1,PERIOD2,PERIOD3 with single ID....
    code :
    ====
     protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
        {
            GridDataInsertItem insertitem = (GridDataInsertItem)e.Item;
    RadListBox box = (RadListBox)insertitem.FindControl("listbox");

    int[] index = box.GetSelectedIndices();
                int i;
                string selectedvalue = "";
                foreach (object radlistbox in index)
                {
                    i = Convert.ToInt32(radlistbox);
                    selectedvalue = selectedvalue + box.Items[i].Value + ' , ' ;
                }
                        string insertQuery = "INSERT into  Holiday_Master1 values('" + holidaycode + "','" + hname + "','" + date + "','" + bname + "','" + sname + "','" + secname + "','" + selectedvalue + "','" + description + "')";
                        SqlCommand.CommandText = insertQuery;
                        SqlCommand.Connection = SqlConnection;
                        SqlConnection.Open();
                        SqlCommand.ExecuteNonQuery();
                        SqlConnection.Close();

    plz anybody  help me....
Back to Top