473,396 Members | 1,886 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,396 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 4422
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 control from dropdownlist. I have property in a...
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 are like <option value=1>New South Wales</option>,...
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 advance for any help! Problem: I am getting...
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 contain the form fields for a basic search on...
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 have to do something special to render the values...
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 (object item in Request.Form) { if...
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 properties with regards to the listitems...
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 controls are inside a user control and this user...
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 some data in form fields and click the buttton ,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.