扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:佚名 来源:Microsoft 2007年11月8日
关键字: Windows
<%@ Register TagPrefix="dgg" Namespace="MyCustomColumn" Assembly="MyCustomColumn" %> |
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="UseCustomColumn.WebForm1" Trace="False" Debug="True"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <LINK rel="stylesheet" type="text/css" href="Styles.css"> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body> <form id="Form1" method="post" runat="server"> <asp:DataGrid id="DataGrid1" runat="server" CssClass="grid" AutoGenerateColumns="False"> <Columns> <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" /> <asp:BoundColumn DataField="OrderID" ReadOnly="True" HeaderText="Order ID"/> <asp:BoundColumn DataField="ShipName" HeaderText="Ship to" ReadOnly="True"/> <asp:BoundColumn DataField="ShipCountry" HeaderText="Country" ReadOnly="True"/> <dgg:DropDownColumn DataField="ShipVia" HeaderText="Ship Method" /> </Columns> </asp:DataGrid> </form> </body> </HTML> |
Dim DDC As MyCustomColumn.DropDownColumn DDC = CType(DataGrid1.Columns(4), MyCustomColumn.DropDownColumn) Dim AL As New ArrayList AL.Add("Shipping Company A") AL.Add("Shipping Company B") AL.Add("Shipping Company C") DDC.DataSource = AL |
<dgg:DropDownColumn DataField="ShipVia" DataTextField="CompanyName" DataValueField="ShipperID" HeaderText="Ship Method" /> |
Dim SQL As String = "SELECT OrderID, ShipName, ShipCountry, ShipVia FROM Orders" Dim DA As SqlDataAdapter = New SqlDataAdapter(SQL, ConnStr) Dim DS As New DataSet DA.Fill(DS, "Orders") 'Dim Cmd As SqlCommand = New SqlCommand(SQL, Conn) 'Conn.Open() 'DataGrid1.DataSource = _ Cmd.ExecuteReader(CommandBehavior.CloseConnection) DataGrid1.DataSource = DS.Tables("Orders").DefaultView SQL = "SELECT ShipperID, CompanyName " & _ "FROM Shippers ORDER BY ShipperID" DA.SelectCommand.CommandText = SQL DA.Fill(DS, "Shippers") DDC.DataSource = DS.Tables("Shippers").DefaultView DataGrid1.DataBind() |
Private Sub DataGrid1_UpdateCommand( ByVal source As Object, _ ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _ Handles DataGrid1.UpdateCommand Dim CustomDDL As DropDownList = _ CType(e.Item.Cells(4).Controls(0), DropDownList) Dim NewShip As Integer = CustomDDL.SelectedValue Dim OrderID As Integer = Int32.Parse(e.Item.Cells(1).Text) Dim SQL As String = "UPDATE Orders SET ShipVia=@Ship WHERE OrderID=@ID" Dim Conn As SqlConnection = New SqlConnection(ConnStr) Dim Cmd As New SqlCommand(SQL, Conn) Cmd.Parameters.Add(New SqlParameter("@Ship", NewShip)) Cmd.Parameters.Add(New SqlParameter("@ID", OrderID)) Conn.Open() Cmd.ExecuteNonQuery() Conn.Close() DataGrid1.EditItemIndex = -1 BindGrid() End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者