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
ankit gaur
1.4k
298
32.6k
Dropdown list value and text issue
Nov 6 2020 6:18 AM
Hello,
this is my code to save the record into database
SqlCommand cmd =
new
SqlCommand(
"INSERT INTO ABC (ComplainerName,"
+
" ComplainerAddress,ComplainerMobile,ComplaintFor,"
+
" BuildingDevelopment,PlantMachCategory,PlantMachSubCategory,PlantMachItem,ItemIdentification)"
+
" VALUES(@lblnamea,@lblFlatno,@lblMobile,@ComplaintFor,@BuildingDevelopment,@ddlAssetCat,"
+
" @ddlAssetSubCat,@ddlAssetItem,@ddlItemIdentification)"
);
cmd.Parameters.AddWithValue(
"@lblnamea"
, lblMeter.Text);
cmd.Parameters.AddWithValue(
"@lblFlatno"
, lblFlatno.Text);
cmd.Parameters.AddWithValue(
"@lblMobile"
, lblMobile.Text);
cmd.Parameters.AddWithValue(
"@ddlAssetCat"
, ddlAssetCat.SelectedValue);
cmd.Parameters.AddWithValue(
"@ddlAssetSubCat"
, ddlAssetSubCat.SelectedValue);
cmd.Parameters.AddWithValue(
"@ddlAssetItem"
, ddlAssetItem.SelectedValue);
cmd.Parameters.AddWithValue(
"@ddlItemIdentification"
, ddlItemIdentification.SelectedValue);
i did save the value in sql database
ddlAssetCat.SelectedValue,dlAssetSubCat.SelectedValue,ddlAssetItem.SelectedValue,ddlItemIdentification.SelectedValue
Now i m showing the record into gridview but i want to show the DataTextField text.
Like ddlAssetCat value is 2 but DataTextField is Eletrical .
I want to show the Eletrical in gridview
using
(SqlCommand cmd =
new
SqlCommand(
"SELECT [ComId],[ComplainerName],[ComplainerAddress],"
+
" [ComplainerMobile],[ComplaintFor],[BuildingDevelopment],[PlantMachCategory],"
+
" [PlantMachSubCategory],[PlantMachItem],[ItemIdentification] "
))
{
using
(SqlDataAdapter sda =
new
SqlDataAdapter())
{
cmd.Connection = myconn;
sda.SelectCommand = cmd;
using
(DataTable dt =
new
DataTable())
{
sda.Fill(dt);
GrdComplaintkList.DataSource = dt;
GrdComplaintkList.DataBind();
DataView dv = dt.DefaultView;
GrdComplaintkList.DataSource = dv;
GrdComplaintkList.DataBind();
}
}
}
Please help
Reply
Answers (
2
)
ASP.Net AJAX Line Chart Control: Populate from Database example
how to get the value from Deserialized data