hi All,
i have this dropdowlist which brings info from DB
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="description"
DataValueField="id" AutoPostBack="true">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:con%>"
SelectCommand="SELECT [Id], [description] FROM [table]">
</asp:SqlDataSource>
code behind
DropDownList1.DataTextField = "description";
DropDownList1.DataValueField = "Id";
DropDownList1.DataBind();
SqlConnection connection = new SqlConnection(strcon);
Label1.Text = DropDownList1.SelectedValue;
SqlCommand command = new SqlCommand("SELECT imagename,Id from [table] where Id=@id", connection);
command.Parameters.Add("@id", DropDownList1.SelectedValue);
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
gvImages.Attributes.Add("bordercolor", "black");
now the problem is this part (Label1.Text = DropDownList1.SelectedValue;)always return the first value which is 1. any help?
Additional info:
if (!IsPostBack)
{
BindGridData();
}