additional Values in ListItem (DropDownList)

  • Thread starter Thread starter Sebi
  • Start date Start date
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
 
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
 
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;
 
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




.
 
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


.


.
 
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


.


.
 
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


.



.


.
 
Back
Top