473,382 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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
6 1691
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: David Given | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Say I have a piece of Javascript that transforms the HTML on a page. (In order to work around CSS bugs.) I could invoke this from the BODY onload...
2
by: Alan Lane | last post by:
Hello world: I'm using Access 2003. I have 2 listboxes. One is a single column. The other has two columns. I can use Dev Ashish's code (thanks Dev!) from the Access MVP Website to accumulate...
1
by: tod4 | last post by:
Hi, My problem: I have query with value klient and product. On my form Im using multiselect box as filter of klient value. Now I would like to use second multiselect on this form for product...
2
by: Steph | last post by:
I have created a multiselect list box control (lbx_comorb) that is populated from a datatable (dt_ptAdmission). The list box populates now problem at all. However the issue is when I load the...
1
by: Clayton Hoyt | last post by:
Hi Folks...this is a wierd issue I've noticed and wanted to know of a) anyone else has noticed this and b) if so, why does it happen. On page load, I have a text box named me.txtMemberName. I...
3
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up...
43
by: Dan2kx | last post by:
Hello AGAIN 'Nother problem to solve.... im trying to set the MultiSelect property within VB for a list box, and i am using the code Me.StaffHols.Multiselect = True and it wont work, it...
5
by: erbrose | last post by:
Hey all, newbie to vb here. I've created a listbox (called lst_county) that gets populated from a Select * From Table in Oracle on load. I've set the MultiSelect to 2 -Extended. I've got some code...
1
by: hemantkamb | last post by:
Hi…. I have created one website with Master and content page . I have taken TreeView Control on master page. And I wants that when I click to tree node the value of tree node is added to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.