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
sri divya
NA
2
2.1k
populating dropdownlist when the grid in editmode
May 20 2014 1:20 PM
I want to populate my dropdownlist when my gv is in editmode,i want the corresponding ID of the record to be displayed in my dropdownlist .Iam specifying the dropdownlist outside the gridview .Thanks.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
DataRowView drv = e.Row.DataItem as DataRowView;
DropDownList ddlnric = (DropDownList)e.Row.FindControl("ddlnric");
string query = "select DISTINCT ecode from Employeesms";
SqlCommand cmd = new SqlCommand(query);
ddlnric.DataSource = GetData(cmd);
ddlnric.DataTextField = "ecode";
ddlnric.DataValueField = "ecode";
ddlnric.DataBind();
ddlnric.SelectedValue = drv["lblcode"].ToString();
}
}
}
Reply
Answers (
1
)
Add Space in a dynamic created gridview after specified row
aspx