Hi,
put the code in question inside IsPostBack check.
If Not Page.IsPostBack Then
'...
ddlClientName.DataSource = objcommand.ExecuteReader
ddlClientName.DataValueField = "ID"
ddlClientName.DataTextField = "Name"
ddlClientName.DataBind()
End if
If the databinding code isn't inside IsPostBack check, DropDownList will be
databound on every request.This causes the effect you mentioned that
selections are not preserved between postbacks
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Hei" <ch******@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
hi,
i using follow code to provide selection in a DropDownList , but it always
return first item value for every selected item after click submit button.
is it about postback problem?
ddlClientName.DataSource = objcommand.ExecuteReader
ddlClientName.DataValueField = "ID"
ddlClientName.DataTextField = "Name"
ddlClientName.DataBind()
hei