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
Valerie Meunier
NA
693
82.8k
filling dropdownlist doesn't work
Apr 14 2021 1:42 PM
Hi,
I try to fill via code-behind a dropdownlist located in a gridview.
But it remains empty.
Thanks for help.
protected
void
GridView1_RowCreated(
object
sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if
((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
{
if
(e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList dd1;
ListItem z;
string
m;
dd1 = (DropDownList)e.Row.FindControl(
"matdd"
);
using
(SqlConnection mConnection =
new
SqlConnection(param.ConnectionString))
{
mConnection.Open();
sql =
"select name from mat order by name"
;
comd =
new
SqlCommand(sql, mConnection);
dtreader = comd.ExecuteReader();
if
(dtreader.HasRows)
{
while
(dtreader.Read())
{
m = dtreader.GetString(0);
z =
new
ListItem(m);
dd1.Items.Add(z);
}
}
dtreader.Close();
mConnection.Close();
}
dd1.ClearSelection();
}
}
}
Reply
Answers (
5
)
Directory.CreateDirectory whith aspnet
asp.net core getting data from json and jquerry