Click here to Skip to main content
12,885,022 members (30,317 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Guys i want to know about how to bind a records to the dropdown list which is in the gridviews item template field.
if i click edit button at runtime then that paricular rows particular dropdown should get filled with the data.
How to achieve this.
any idea??
Posted 11-Feb-13 1:34am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

use gridview databound event for that... refer following code

protected void test_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddl = (DropDownList)e.Row.FindControl("yourDropDownListID");
                ddl.DataSource = //assing your datasorce here to bind to your dropdown list
                ddl.DataBind();
            }
        }
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Hi Sachin,


on the grid row bound event

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Control ctrl = e.Row.FindControl("ddlName");
if (ctrl != null)
{
DropDownList ddl = (DropDownList)ctrl;
DataTable dt  =GetData(); // get your data either in list or datatable
ddl.DataSource = dt  ;    // Specify  here either list or datatable 
ddl.DataTextField = "Name"; // specify here  display Member
ddl.DataValueField = "Id"; // specify here  value member
ddl.DataBind();
}
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100