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

additional Values in ListItem (DropDownList)

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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

"Sebi" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
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

Nov 18 '05 #2

P: n/a
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;
Nov 18 '05 #3

P: n/a
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?

<an*******@discussions.microsoft.com> wrote in message
news:0a****************************@phx.gbl...
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

"Sebi" <an*******@discussions.microsoft.com> wrote in

message
news:03****************************@phx.gbl...
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

.

Nov 18 '05 #4

P: n/a
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 HTMLItems rendered as <option value='Value'>Text</option>
Where do you put additional items members and why you need them?
<an*******@discussions.microsoft.com> wrote in message
news:0a****************************@phx.gbl...
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
>
>"Sebi" <an*******@discussions.microsoft.com> wrote in

message
>news:03****************************@phx.gbl...
>> 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
>
>
>.
>

.

Nov 18 '05 #5

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
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?

<an*******@discussions.microsoft.com> wrote in message
news:0a****************************@phx.gbl...
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
>
>"Sebi" <an*******@discussions.microsoft.com> wrote in
message
>news:03****************************@phx.gbl...
>> 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
>
>
>.
>

.

Nov 18 '05 #6

P: n/a
Also thought about concatenating, guess this is the
easiest way!

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

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

Thier r many ways to achive it.
Thanks,

sswalia
MCSD, MCAD, OCA
"Sebi" <an*******@discussions.microsoft.com> wrote in messagenews:0c****************************@phx.gbl...
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?
>
><an*******@discussions.microsoft.com> wrote in message
>news:0a****************************@phx.gbl...
>> 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
>> >
>> >"Sebi" <an*******@discussions.microsoft.com> wrote
in >> message
>> >news:03****************************@phx.gbl...
>> >> 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
>> >
>> >
>> >.
>> >
>
>
>.
>

.

Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.