TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Deepa Sudhir
NA
35
21.2k
how to get selectedvalue of dropdown populated frm database
Mar 12 2015 3:09 AM
I have a dropdownlist box
<
asp
:
DropDownList
ID
="drpAvailableColours"
runat
="server"
AutoPostBack
="True"
OnSelectedIndexChanged
="DropDownList1_SelectedIndexChanged"
EnableViewState
="true"
>
</
asp
:
DropDownList
>
I am populating the database using the code---
DataSet
dsColours =
new
DataSet
();
string
strColourQuery =
"Select ProductName,ColourCode from ProductDet where ProductId in (select ProductId from ProductMaster where CatId = '1' and SubCatId='1' and BrandId='2' and SubBrandId='7')"
;
dsColours = db.GetTableDefinedDataSet(strColourQuery,
"ProductColours"
);
if
(dsColours.Tables[
"ProductColours"
].Rows.Count > 0)
{
var
query = dsColours.Tables[
"ProductColours"
].AsEnumerable()
.GroupBy(x => x.Field<
string
>(
"ProductName"
).ToString())
.Select(x => x.First());
foreach
(
DataRow
DistinctProducts
in
query)
{
drpAvailableColours.Items.Add(
new
ListItem
(DistinctProducts[
"ProductName"
].ToString(), DistinctProducts[
"ColourCode"
].ToString()));
}
}
else
{
//postback
Label1.Text = drpAvailableColours.SelectedValue.ToString();
}
But I don't get the selected value from the dropdownlist in the label1
Also
DropDownList1_SelectedIndexChanged doesn't trigger when I select from dropdownlist
Reply
Answers (
3
)
Covert Text into Image using C#.Net
show popup on browser close button