zoukankan      html  css  js  c++  java
  • [.net]DataGrid中绑定DropDownList[转]

    [.net]DataGrid中绑定DropDownList

    在DataGrid中加入DropDownList:
    <asp:TemplateColumn HeaderText="au_lname">
             <itemtemplate>
         <asp:Label runat="server"
           Text='<%# DataBinder.Eval(Container.DataItem, "au_lname") %>'/>
             </itemtemplate>
             <edititemtemplate>
         <asp:DropDownList runat="server"
           DataSource='<%# GetDataTable1() %>'
           DataTextField="au_lname"
           id="au_lname" />
    DropDownList绑定数据代码:
    public DataTable GetDataTable1(){
    String selectCmd = "select DISTINCT au_lname  from Authors";
    SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;database=pubs;Integrated Security=SSPI");
    SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);
    DataSet ds = new DataSet();
    myCommand.Fill(ds, "au_lname");
    DataTable dt = ds.Tables["au_lname"];
    return dt;
         }
  • 相关阅读:
    cf C. Vasya and Robot
    zoj 3805 Machine
    cf B. Vasya and Public Transport
    cf D. Queue
    cf C. Find Maximum
    cf B. Two Heaps
    cf C. Jeff and Rounding
    cf B. Jeff and Periods
    cf A. Jeff and Digits
    I Think I Need a Houseboat
  • 原文地址:https://www.cnblogs.com/stevenxiao/p/409747.html
Copyright © 2011-2022 走看看