What Event Exactly?

I need to populate a dropdown listbox named "sub category" once the user the clicks his desired selection in the dropdown listbox named "category" e.g. clothing has subcategories like gent's clothes and ladies clothes.

I need to know which event i have to use? Im not sure in what event i have to put my code in exactly.Please help.

[336 byte] By [Maxood] at [2007-12-17]
# 1
Maxood wrote:
I need to populate a dropdown listbox

Do you mean combobox ?

Maxood wrote:
once the user the clicks his desired selection in the dropdown listbox ....I need to know which event i have to use? Im not sure in what event i have to put my code in exactly.Please help.

I think you need SelectedIndexChanged

Remco

RemcoJVG at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2
okay i did try onSelectedIndexChanged =""populate", embeded this value in the server control tag as : <asp:dropdownlist id="cboCat" width="150" onselectedItemChanged="populate" runat="server"/>.

The populate procedure is as follows:
Sub populate(sender as object, e as eventargs)
'code to populate subcategory dropdown list box
End Sub

But it is not working , whenever i select any other item in the category listbox the first item gets selected automatically.Need to sort out this problem.
Please look in to it and let me know what to do...thanx

Maxood at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 3

In the code it is onSelectedIndexChanged, please rectify it. Please let me know how to do it

Maxood at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 4
Hey
set AutoPostBack property to true of that dropdown list in aspx page.
DineshSinghBisht at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 5
I did set the AutoPostBack property to true, but with this i get the first item of the dropdown listbox selected everytime i try to select any other item i.e. if there are four items in the order clothing, food, stores, homeliving and i select stores then clothing gets selected automatically.
why is that? I jus want this dropdown listbox to leave with the value i selected . Please look into it and justify your solution
Maxood at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 6

okay let me just explain the heart of the problem. There is this dropdownlist populated with vales from SQL Server 7.0 database i.e. "clothing","food","stores" and "homeliving".
Now just the first time when the user selects any value from this list the first value "clothing" gets selected and on the status bar it comes "opening page http://maxood/5040/watal.aspx" .This means the page gets loaded again.

Now how can i stop it!!?

Here is my code for the page load event:

Dim strConnection as String = "server=Maxood;database=watal;user id=sa;password=;"
Dim strSql as String = "Select categoryname from category"

Dim objConn1 as New SqlConnection(strConnection)
Dim cmdCat as New SqlCommand(strSql,objConn1)

objConn1.Open()
cboCat.DataSource = cmdCat.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
cboCat.DataTextField = "categoryname"
cboCat.DataBind()


strSql = "Select * from city"
Dim objConn2 as New SqlConnection(strConnection)
Dim cmdCity as New SqlCommand(strSql,objConn2)

objConn2.Open()

cbocity.DataSource =cmdCity.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
cboCity.DataTextField="city"
cboCity.DataBind()

Please explain!!

Maxood at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 7
I feel you are writting this code on page_load.
if you are doing so than please check for IsPostBack

like this

Page_load(even ......)
{
if (!IsPostBack)
{
BindingCode.....

}
}

I am writting it in C# but I hope It is understood.

I hope this will be helpful.

is iT ?

DineshSinghBisht at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 8

thnax a lot for this tip. I need to know what event is generated when a user selects a new item in a dropdown list box.

Please give me an exaple through code...thanx.

Maxood at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 9
use codebehind

private void ComboName_SelectedIndexChanged(object sender, System.EventArgs e)
{
Response.Write("I am here");

}

THis will help..

DineshSinghBisht at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified