<asp:GridView runat="server" id="gv" DataKeyNames="CustomerID" 
            AutoGenerateColumns="False">
           <Columns>
               <asp:HyperLinkField DataNavigateUrlFields="CustomerID" 
                   DataNavigateUrlFormatString="./CustomerDetails.aspx?CustomerID={0}" 
                   DataTextField="CustomerID" HeaderText="客户编号" />
               <asp:BoundField DataField="CompanyName" HeaderText="客户名称" ReadOnly="True" 
                   SortExpression="CompanyName" />
               <asp:BoundField DataField="ContactName" HeaderText="联系人" 
                   SortExpression="ContactName" />
               <asp:BoundField DataField="ContactTitle" HeaderText="联系主题" 
                   SortExpression="ContactTitle" />
               <asp:TemplateField HeaderText="城市">
                   <ItemTemplate>
                       <asp:DropDownList runat="server" ID="cityDpt"></asp:DropDownList>
                   </ItemTemplate>
               </asp:TemplateField>
           </Columns>
        </asp:GridView>
<asp:DropDownList runat="server" ID="cityDpt"></asp:DropDownList>
里面的值怎么绑定啊,后台绑定不用SqlDataSource..

解决方案 »

  1.   

    用findControl先找到cityDpt,
    然后直接像正常的控件一样绑定就可以了。
      

  2.   

    在绑定事件里FindControl("cityDpt") as DropDownList ,然后对DropDownList 进行数据源的提供和绑定即可
      

  3.   

     在GridView 的 datarowround 的事件里找 到  dropdownlist 控件  
     然后在这个事件内。
     绑定数据。
      如: protected void gv_RowDataBound(object sender, GridviewRowEventArgs e)
            {
               DropDownList dr= (DropDownList )e.Item.FindControl("cityDpt");
                 dr.DataValueField = "标识ID";
                 dr.DataTextField = "标识NANE";
                 dr.DataSource = 数据源;    
             }  
      

  4.   

    <asp:DropDownList ID="ddlValues" Width="106px" DataTextField="PV_Value" DataSource='<%# Values %>' DataValueField="PropertyValues_ID" runat="server"></asp:DropDownList>
    if(ViewState["values"] == null)
                        ViewState.Add("values", null);
    public List<PropertyValues> Values//父属性值集合
            {
                get { return (List<PropertyValues>)ViewState["values"]; }
                set { ViewState["values"] = value; }
            }页面加载时候给Values赋值
      

  5.   

    http://blog.csdn.net/xianfajushi/archive/2008/11/30/3413317.aspx