Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DropDownList peoblem !?

Reply
Thread Tools

DropDownList peoblem !?

 
 
=?Utf-8?B?VGh1YmFpdGk=?=
Guest
Posts: n/a
 
      12-26-2004
Hi,

I am using DropDownList. Then, I am adding the DropDownList item from the
database and it is work. When I check the value of the items in the
Page_Load, it is appear without problem. The problem appears when
SelectedIndexChanged is active; the value of the item is always "1".

This is ASP.NET code:

<aspropDownList id="categoryDropDownList" runat="server"
DataTextField="name" DataValueField="id"></aspropDownList>

and this is my C# code (code behind):

private void Page_Load(object sender, System.EventArgs e) {
// Put user code to initialize the page here

DataTable categoryDataTable = sweCategory.SelectAll();
categoryDropDownList.DataSource = categoryDataTable;
categoryDropDownList.DataBind();
}
....
....
....
private void categoryDropDownList_SelectedIndexChanged(object sender,
System.EventArgs e) {
SqlString categoryId = categoryDropDownList.SelectedItem.Value;

this.addItemPanel.Visible = false;
this.doneLabel.Text = categoryId.ToString();
}

Any help please ?!?


Thanks
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGh1YmFpdGk=?=
Guest
Posts: n/a
 
      12-27-2004
I solved the problem and this is the new code

private void Page_Load(object sender, System.EventArgs e) {
// Put user code to initialize the page here

if(!IsPostBack) {
DataTable categoryDataTable = sweCategory.SelectAll();
categoryDropDownList.DataSource = categoryDataTable;
categoryDropDownList.DataBind();

categoryDropDownList.Items.Insert(0, new ListItem("","0"));
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList inside GridView: How to set SelectedIndex for the DropDownList? keithb ASP .Net 1 11-01-2006 05:24 AM
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-29-2005 07:44 AM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-23-2005 01:31 PM
databinding a Dropdownlist to another dropdownlist tshad ASP .Net 8 10-19-2005 10:00 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57