467,901 Members | 1,756 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,901 developers. It's quick & easy.

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


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
  • viewed: 1446
Share:
6 Replies
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
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
Hi Mahesh,

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

HTH
Kalpesh

Nov 19 '05 #4
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
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
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.

Similar topics

11 posts views Thread by David Given | last post: by
1 post views Thread by tod4 | last post: by
2 posts views Thread by Steph | last post: by
1 post views Thread by Clayton Hoyt | last post: by
3 posts views Thread by kaosyeti via AccessMonster.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.