Here is aspx code you can refer.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
SelectCommand="SELECT [col_id], [col_name], [col_image] FROM [asptest]"></asp:SqlDataSource>
<asp:DropDownList runat="server" ID="Name" DataSourceID="SqlDataSource1" DataTextField="col_name" DataValueField="col_id"
OnSelectedIndexChanged="Name_SelectedIndexChanged" AutoPostBack="true" />
<asp:DropDownList runat="server" ID="image" DataSourceID="SqlDataSource1" DataTextField="col_image" DataValueField="col_id" />
In code behind of the page, add following function
protected void Name_SelectedIndexChanged(object sender, EventArgs e)
{
image.SelectedValue = Name.SelectedValue;
}
Alternatively, this can be achieved using javascript also to avoid a trip to server.
Hope this helps.
__________________
Kushal Kaleshwari
Application Architect
|