|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Enthusiast
![]() Join Date: Oct 2008
Posts: 46
|
Dropdownlist ASP.Net With Database Question
Hello everyone.
I have been trying to do something with a dropdownlist but it is not working. This is my default2.aspx code ASP Code:
This is my code behind code Csharp Code:
What I am trying to do here is to show in my Label "HTMLContent" some other value than only "PrijsItem" Which is the DataValueField of my dropdownlist. I want to show the Item Name AND the price of the item. As an extra thing I am trying to make something similair to ordering .. like when a customer orders multiple Items and then he can calculate the price of them all. Thanks in advance |
|
|
|
|
|
#2 | |
|
SitePoint Enthusiast
![]() Join Date: Oct 2009
Location: Mid-West USA
Posts: 30
|
Quote:
Should be..... HTMLContent.Text = DropDownList1.SelectedItem.Text; And "EnableViewState="true"" needs to be in the declaration on the .aspx page so it maintains values on postback. |
|
|
|
|
|
|
#3 |
|
SitePoint Enthusiast
![]() Join Date: Oct 2008
Posts: 46
|
Thanks a bunch.
But what if I want to display more columns in more labels than only two? What can I use other that DataValueField? Thanks again. |
|
|
|
|
|
#4 |
|
SitePoint Enthusiast
![]() Join Date: Oct 2009
Location: Mid-West USA
Posts: 30
|
Sure, something like this....
Code:
SqlCommand objCommand = new SqlCommand(Sql String, objConnect);
SqlDataReader objDataReader = objCommand.ExecuteReader();
if(objDataReader.Read()) {
lblID.Text = objDataReader["ColumnName1"].ToString();
lblName.Text = objDataReader["ColumnName2"].ToString();
lblPassword.Text = objDataReader["ColumnName3"].ToString();
}
objDataReader.Close();
objConnect.Close();
|
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 20:19.









Linear Mode
