473,246 Members | 1,517 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,246 software developers and data experts.

Adding additional properties to list items in a dropDownlist through inheritance

RSH
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 collection, Text and Value. I need
to add a DivisionID, and DepartmentID.

I assumed i could simply override the ListItem class and add the additional
properties. is this in fact the case? If so what would the code look like?

Thanks in advance for any information you can provide.

Ron
Jan 2 '07 #1
1 3153
"RSH" <wa*************@yahoo.comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
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 collection, Text and Value.
That's right.
I need to add a DivisionID, and DepartmentID.
OK.
I assumed i could simply override the ListItem class and add the
additional properties. is this in fact the case? If so what would the
code look like?
Run your web app and navigate to the page with the DropDownList - do a View
Source. The DropDownList webcontrol simply creates the <selectHTML tag,
and the various <optionelements in it. Whereas you could override the
ListItem class in the way you describe by adding additional properties,
ASP.NET would simply ignore them when creating the HTML markup to stream
down to the client.
Thanks in advance for any information you can provide.
Fortunately, this is quite easy to work around.

<asp:DropDownList ID="cmbTest" runat="server" />
<asp:Button ID="cmdTest" runat="server" Text="Test" OnClick=cmdTest_Click />

protected void Page_Load(object sender, EventArgs e)
{
ListItem objItem = null;

objItem = new ListItem();
objItem.Value = "1񦶩";
objItem.Text = "One";
cmbTest.Items.Add(objItem);

objItem = new ListItem();
objItem.Value = "4񧱰";
objItem.Text = "Two";
cmbTest.Items.Add(objItem);
}

protected void cmdTest_Click(object sender, EventArgs e)
{
string strValue = cmbTest.SelectedValue.Split('')[0];
string strDivision = cmbTest.SelectedValue.Split('')[1];
string strDepartment = cmbTest.SelectedValue.Split('')[2];
}
Jan 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
6
by: Sebi | last post by:
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...
2
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.....
4
by: starwiz | last post by:
I'm trying to use the DataGrid's editing with a DropDownList. I've tried using every code sample I've seen and none of them seem to be able to solve my problem. When I call...
2
by: estafford | last post by:
I have a dropdownlist control that is filled using a database query. I also want to add an additional option to the list that is not pulled from the database. How can I go about doing that? ...
3
by: Stephen Adam | last post by:
Hi there, I'm sure i'm missing something really simple here, all i want to do is get the value of the selected item in a list box. Even after much fiddling about last night I still could not get...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
5
by: Mike | last post by:
In ASP.NET 2.0 I have a dropdownlist populated from a sqldatasource. The dropdownlist values are successfully populated from a database table. I would like to add the value "Select Company" which...
1
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.