AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 get value of dropdownlist in gridview
Posted by srinivas on  2/13/2012 6:46:31 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
i have a gridview within dropdownlist i want to get value of dropdownlist selected value

Post Your Reply Post New Question

 Viewer's Reply
get value of dropdownlist in gridview
Answered By Yrui Kosenko on 3/5/2012 1:49:25 AM
1. Add DataSet - TA.GetData();
2. Add - RowDataBound for GridView

protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label _lbl_id = (Label)e.Row.FindControl("lbl_id");
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))
|| (e.Row.RowState == DataControlRowState.Edit))
{
int lbl_id = Convert.ToInt32(_lbl_id.Text);
DropDownList ddl = (DropDownList)e.Row.FindControl("DDL");
ddl.DataSource = TA.GetData();
ddl.DataValueField = "idR";
ddl.DataTextField = "nameR";
ddl.DataBind();
ddl.SelectedValue = lbl_id.ToString();
}
}
}
}
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Many .NET teams are underperforming, is yours?
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
Take Advantage of Oracle's 2 Day DBA Course