displying values in dropdownlistbox
hi ,
iam using asp.net 2003,In that i had use a droplistbox to bind the datas in page_load events as follows
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
myconnection = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; " & _
"Data Source=C:\Inetpub\wwwroot\upload\mydatabase.mdb")
myda = New OleDbDataAdapter("Select * from t_table ", myconnection)
ds = New DataSet()
myda.Fill(ds, "AllTables")
DropDownList1.DataSource = ds
DropDownList1.DataSource = ds.Tables(0)
DropDownList1.DataTextField = ds.Tables(0).Columns("imagepath").ColumnName.ToStr ing()
DropDownList1.DataValueField = ds.Tables(0).Columns("name").ColumnName.ToString()
DropDownList1.DataBind()
End Sub
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Label1.Text = DropDownList1.SelectedItem.Value.ToString
End Sub
And setting autopostback property for dropdonlistbox =true.
after running this webpage when selecting any values in dropdownlistbox its first field values were displaying in label1 ,b'coz of writing code in page_load events. what to do for this.....
jayakumar
|