.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to Bind Dropdownlist in GridView

Posted By: priya     Posted Date: April 13, 2011    Points:5   Category :ASP.Net
Hi,

How can i bind the dropdownlist from database inside GridView column under EditItemTemplate in asp.net. I am using C# as my code language

Thanks In Advance
Priya

Responses
Author: Kannan C S             
Posted Date: April 14, 2011     Points: 20   

Hi,

try to bind dropdown in gridview rowdatabound event.



Author: shankey             
Posted Date: April 14, 2011     Points: 20   

hellow,

Try following sample code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string celltext = e.Row.Cells[1].Text; // give the another cell index
DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
dll.DataSource=dt;
dll.DataBind();
}
}

Thanks


Shankey


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend