Multiselect on page load..? how to solve this..?

  • Thread starter =?iso-8859-1?Q?=BF_Mahesh_Kumar?=
  • Start date
?

=?iso-8859-1?Q?=BF_Mahesh_Kumar?=

Hi groups,

Control name : ListboxID (lstCertification), selection mode=mutliselect.

On Pageload i'm assinging string lstSplit="1/3/6/8" of the previously selected listindex id's. Now on the page load for updation, i have to reload the selected items again with the same string "1/3/6/8" to be selected in my multiselect list box.


Its asking me to convert object to int... for list selection. but how to achieve this..?
--------------------------------------

string[] result;

string lstSplit;

lstSplit = "1/3/7/8";

char[] sep = { '/' };

Array a = lstSplit.Split(sep);

for (int i = 0; i < a.Length; i++)

{

lstCertification.SelectedIndex = a.GetValue(i) ; << -------------- casting from Obj to Int..??

lstCertification.SelectedItem.Selected = true;

}

---------------------------------------

I want to multiselect my listbox on page load with the string value stored in Database "1/3/5/6/8" etc to listbox mulitselection iindex..? is there any other way to solve this..???



Mahesh
 
K

Kalpesh

Hi Mahesh,

In the loop, you can do the following

for(....)
{
int i = (int)a;
lstCertification.Items.selected = true;
}

HTH
Kalpesh
 
¿

¿ Mahesh Kumar

not working..

-------------------

string lstSplit;

lstSplit = rdrExmr["airman_cert_held"].ToString(); < ----------
{ 1/3/4/5/6/ } returns

char[] sep = { '/' };

Array a = lstSplit.Split(sep);

for (int i = 0; i < a.Length; i++)

{

int ij = (int)a; /// giving error here....

lstCertification.Items.Selected = true;

}

-------------------

error messa-ge : Cannot apply indexing with [] to an expression of type
'System.Array'

Mahes
 
P

Praveen

Hi mahesh,
did u try with this code..
its working from my side..

lst.SelectedIndex =
lst.Items.IndexOf(lst.Items.FindByText(@"1/1/2004"));

Bye,
Praveen P.
 
K

Kalpesh

Hi Mahesh,

If you are storing int in the Array, then it should work

Try this
int ij = (int)(a.GetValue(i));

HTH
Kalpesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top