Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
how to display the value of the column in drop down list
Joma Rajab
8y
291
1
Reply
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
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
How to convert google earth KML File into Images in c# ?
My Asp.NET application Get logout just on pages who have cry