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

RadListBox not setting multiple values

2 Answers 173 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
satya chaluvadi
Top achievements
Rank 1
satya chaluvadi asked on 04 May 2010, 10:25 PM

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 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 06 May 2010, 09:26 AM
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.
0
Velmurugan
Top achievements
Rank 1
answered on 04 Nov 2011, 07:15 AM
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....
Tags
ListBox
Asked by
satya chaluvadi
Top achievements
Rank 1
Answers by
Yana
Telerik team
Velmurugan
Top achievements
Rank 1
Share this question
or