472,342 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

additional Values in ListItem (DropDownList)

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

Similar topics

0
by: adam | last post by:
i have custom user control and i'm trying to pass values to custom user control......I need help it seems to me i cannot pass the value to user...
2
by: Sean | last post by:
HI There, I would like to find out the syntax for having option values different from the ones displayed on the page? In regular HTML the forms...
4
by: Todd Perkins | last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually rely on google. So I hope I have enough info contained. Thank you in...
1
by: osh | last post by:
All, I am having trouble using the PostBackUrl feature in .NET 2.0. I have several User Controls that are on a MasterPage. The User Controls...
3
by: Sully | last post by:
Hi, I am having a small problem generating an e-mail via an online form. I am creating an e-mail using the MailMessage command and I know that you...
9
by: Kevin Blount | last post by:
Here's the code I tried, and found it failed... <form runat="server" method="post" name="CreditCardForm" id="CreditCardForm"> <% foreach...
1
by: RSH | last post by:
Hi, I have a situation where I need to add several "Hidden" properties to list items in a dropdownlist. By default the DropDownList item has two...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the...
0
by: chandrasekhar | last post by:
Hi I have developed a web page with some controls. I put all of them in session variables. I passed this values in the page. When an user enter...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.