By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 1,847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

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

P: n/a

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

Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Mahesh,

In the loop, you can do the following

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

HTH
Kalpesh

Nov 19 '05 #2

P: n/a
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[i]; /// giving error here....

lstCertification.Items[i].Selected = true;

}

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

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

Mahes
"Kalpesh" <sh*********@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi Mahesh,

In the loop, you can do the following

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

HTH
Kalpesh

Nov 19 '05 #3

P: n/a
Hi Mahesh,

Change the line to
int ij = (int)a.GetValue(i);

HTH
Kalpesh

Nov 19 '05 #4

P: n/a
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.
Mahesh Kumar wrote:
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 reloadthe 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


Nov 19 '05 #5

P: n/a
int ij = (int)a.GetValue(i); --> Specified cast is not valid.

Mahesh

"Kalpesh" <sh*********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi Mahesh,

Change the line to
int ij = (int)a.GetValue(i);

HTH
Kalpesh

Nov 19 '05 #6

P: n/a
Hi Mahesh,

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

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

HTH
Kalpesh

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.