additional Values in ListItem (DropDownList)

S

Sebi

Hello all,

I'm thinking about overwriting the ListItem, so it can
contain x additional values (not only one).
Has anybody ever tried this?
Has someone got an example (C#)?
Can DropDownList handle overwritten Items, or will
additional Data be lost?

Thanks for any advice.

Sebi
 
A

Anatoly

You can write function which fills the dropdownlist
Inside this function add all additional values you want.
All you must remember is to use this function
For example

void BindCombo(Dropdownlist Combo, DataTable Data, string TextField, string
ValueField, bool ShowDefaultItem)
{
Combo.DataSource = Data;

Combo.DataValueField = ValueField;

Combo.DataTextField = TextField;

Combo.DataBind();

if(ShowDefaultItem)

{

Combo.Items.Insert(0, new System.Web.UI.WebControls.ListItem("My default
Item Text", "My Default Item Value"));

}


}
HTH
 
G

Guest

Soory! Didnt express myself corect!

I mean more than Text and Value P E R I T E M!
(so in the end I can Fill like this:
Combo.DataSource = Data;
Combo.DataValueField[1] = ValueField;
Combo.DataValueField[2]= SecondValueField;
Combo.DataValueField[3]= ThirdValueField;
 
A

Anatoly

But finally dropdown will be rendered as <select> tag in HTML
Items rendered as <option value='Value'>Text</option>
Where do you put additional items members and why you need them?

Soory! Didnt express myself corect!

I mean more than Text and Value P E R I T E M!
(so in the end I can Fill like this:
Combo.DataSource = Data;
Combo.DataValueField[1] = ValueField;
Combo.DataValueField[2]= SecondValueField;
Combo.DataValueField[3]= ThirdValueField;
.
.
.
Combo.DataTextField = TextField;
Combo.DataBind();
)



-----Original Message-----
You can write function which fills the dropdownlist
Inside this function add all additional values you want.
All you must remember is to use this function
For example

void BindCombo(Dropdownlist Combo, DataTable Data, string TextField, string
ValueField, bool ShowDefaultItem)
{
Combo.DataSource = Data;

Combo.DataValueField = ValueField;

Combo.DataTextField = TextField;

Combo.DataBind();

if(ShowDefaultItem)

{

Combo.Items.Insert(0, new
System.Web.UI.WebControls.ListItem("My default
Item Text", "My Default Item Value"));

}


}
HTH




.
 
S

Sebi

Thats Right,
need to overwrite the rendering! That's what I've never
done until now and what I'm searching a sample for.

My Application is Database-based, in the ComboBox I show
Name as Text and have ID stored as Value.
Now I'm having associated Data Like a Prefix witch
should be shown in a Text Box after a selection.
Because I want this to work faster I want to store this
Prefix in the ComboBox.

S
-----Original Message-----
But finally dropdown will be rendered as <select> tag in HTML
Items rendered as <option value='Value'>Text</option>
Where do you put additional items members and why you need them?

Soory! Didnt express myself corect!

I mean more than Text and Value P E R I T E M!
(so in the end I can Fill like this:
Combo.DataSource = Data;
Combo.DataValueField[1] = ValueField;
Combo.DataValueField[2]= SecondValueField;
Combo.DataValueField[3]= ThirdValueField;
.
.
.
Combo.DataTextField = TextField;
Combo.DataBind();
)



-----Original Message-----
You can write function which fills the dropdownlist
Inside this function add all additional values you want.
All you must remember is to use this function
For example

void BindCombo(Dropdownlist Combo, DataTable Data, string TextField, string
ValueField, bool ShowDefaultItem)
{
Combo.DataSource = Data;

Combo.DataValueField = ValueField;

Combo.DataTextField = TextField;

Combo.DataBind();

if(ShowDefaultItem)

{

Combo.Items.Insert(0, new
System.Web.UI.WebControls.ListItem("My default
Item Text", "My Default Item Value"));

}


}
HTH

Hello all,

I'm thinking about overwriting the ListItem, so it can
contain x additional values (not only one).
Has anybody ever tried this?
Has someone got an example (C#)?
Can DropDownList handle overwritten Items, or will
additional Data be lost?

Thanks for any advice.

Sebi


.


.
 
S

SSW

U can concatinate all the values and store as Values(of <option
value='Value'>Text</option>). Then u can process this value part of Dropdown
string vai JavaScript Or on Server(VB/C#). Up to u.

Second Option, Create DataTable store it in view state and Process it on
server.

Thier r many ways to achive it.


Thanks,

sswalia
MCSD, MCAD, OCA
Sebi said:
Thats Right,
need to overwrite the rendering! That's what I've never
done until now and what I'm searching a sample for.

My Application is Database-based, in the ComboBox I show
Name as Text and have ID stored as Value.
Now I'm having associated Data Like a Prefix witch
should be shown in a Text Box after a selection.
Because I want this to work faster I want to store this
Prefix in the ComboBox.

S
-----Original Message-----
But finally dropdown will be rendered as <select> tag in HTML
Items rendered as <option value='Value'>Text</option>
Where do you put additional items members and why you need them?

Soory! Didnt express myself corect!

I mean more than Text and Value P E R I T E M!
(so in the end I can Fill like this:
Combo.DataSource = Data;
Combo.DataValueField[1] = ValueField;
Combo.DataValueField[2]= SecondValueField;
Combo.DataValueField[3]= ThirdValueField;
.
.
.
Combo.DataTextField = TextField;
Combo.DataBind();
)




-----Original Message-----
You can write function which fills the dropdownlist
Inside this function add all additional values you want.
All you must remember is to use this function
For example

void BindCombo(Dropdownlist Combo, DataTable Data,
string TextField, string
ValueField, bool ShowDefaultItem)
{
Combo.DataSource = Data;

Combo.DataValueField = ValueField;

Combo.DataTextField = TextField;

Combo.DataBind();

if(ShowDefaultItem)

{

Combo.Items.Insert(0, new
System.Web.UI.WebControls.ListItem("My default
Item Text", "My Default Item Value"));

}


}
HTH

message
Hello all,

I'm thinking about overwriting the ListItem, so it can
contain x additional values (not only one).
Has anybody ever tried this?
Has someone got an example (C#)?
Can DropDownList handle overwritten Items, or will
additional Data be lost?

Thanks for any advice.

Sebi


.


.
 
S

Sebi

Also thought about concatenating, guess this is the
easiest way!

S
-----Original Message-----
U can concatinate all the values and store as Values(of <option
value='Value'>Text</option>). Then u can process this value part of Dropdown
string vai JavaScript Or on Server(VB/C#). Up to u.

Second Option, Create DataTable store it in view state and Process it on
server.

Thier r many ways to achive it.


Thanks,

sswalia
MCSD, MCAD, OCA
Thats Right,
need to overwrite the rendering! That's what I've never
done until now and what I'm searching a sample for.

My Application is Database-based, in the ComboBox I show
Name as Text and have ID stored as Value.
Now I'm having associated Data Like a Prefix witch
should be shown in a Text Box after a selection.
Because I want this to work faster I want to store this
Prefix in the ComboBox.

S
-----Original Message-----
But finally dropdown will be rendered as <select> tag
in
HTML
Items rendered as <option value='Value'>Text</option>
Where do you put additional items members and why you need them?

Soory! Didnt express myself corect!

I mean more than Text and Value P E R I T E M!
(so in the end I can Fill like this:
Combo.DataSource = Data;
Combo.DataValueField[1] = ValueField;
Combo.DataValueField[2]= SecondValueField;
Combo.DataValueField[3]= ThirdValueField;
.
.
.
Combo.DataTextField = TextField;
Combo.DataBind();
)




-----Original Message-----
You can write function which fills the dropdownlist
Inside this function add all additional values you want.
All you must remember is to use this function
For example

void BindCombo(Dropdownlist Combo, DataTable Data,
string TextField, string
ValueField, bool ShowDefaultItem)
{
Combo.DataSource = Data;

Combo.DataValueField = ValueField;

Combo.DataTextField = TextField;

Combo.DataBind();

if(ShowDefaultItem)

{

Combo.Items.Insert(0, new
System.Web.UI.WebControls.ListItem("My default
Item Text", "My Default Item Value"));

}


}
HTH

message
Hello all,

I'm thinking about overwriting the ListItem, so
it
can
contain x additional values (not only one).
Has anybody ever tried this?
Has someone got an example (C#)?
Can DropDownList handle overwritten Items, or will
additional Data be lost?

Thanks for any advice.

Sebi


.



.


.
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top