i need to show the selected value from database in drop down list and this drop down list contains items on of them is the selected one from database
- asp.net code
-
- <asp:DropDownList ID="DropDownList3" runat="server" EnableViewState="true" DataSourceID="SqlDataSource7" AppendDataBoundItems="true" DataTextField="Name" DataValueField="SId" Width="130px" Height="25px"> <asp:ListItem>Select School</asp:ListItem> </asp:DropDownList>
- <asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [SId],[Name] FROM [School]"></asp:SqlDataSource>
-
-
-
-
-
-
- SqlDataReader myReader = null;
- SqlCommand query = new SqlCommand(@"select * from dbo.Cousres INNER JOIN dbo.School ON
- dbo.School.SId=dbo.Cousres.SId where dbo.Cousres.CourseId='" + TextBox7.Text + "'", conn);
- SqlDataAdapter da = new SqlDataAdapter();
- myReader = query.ExecuteReader();
- while (myReader.Read())
- {
- TextBox3.Text = (myReader["CourseId"].ToString());
- TextBox4.Text = (myReader["CousreName"].ToString());
- DropDownList3.SelectedValue= (myReader["Name"].ToString());
- Edit.Visible = false;
- }
please help
thnak you