扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
<asp:ControlParameter Name="FirstKey" ControlID="MasterGrid" PropertyName="SelectedDataKey.Values[0]"/> <asp:ControlParameter Name="SecondKey" ControlID="MasterGrid" PropertyName="SelectedDataKey.Values[1]"/> |
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Response.Write("<b>SelectedDataKey.Value: </b>" & Server.HtmlEncode(GridView1.SelectedDataKey.Value) & "<br />") Response.Write("<b>DataKey Field 1: </b>" & Server.HtmlEncode(GridView1.SelectedDataKey.Values("au_id")) & "<br />") Response.Write("<b>DataKey Field 2: </b>" & Server.HtmlEncode(GridView1.SelectedDataKey.Values("title_id")) & "<br />") End Sub Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Dim key As DataKey Response.Write("<b>GridView DataKeys: </b><br />") For Each key In GridView1.DataKeys Response.Write(Server.HtmlEncode(key.Values(0)) & ", ") Response.Write(Server.HtmlEncode(key.Values(1)) & "<br/>") Next End Sub |
<script runat="server"> Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) OrderDetailsDataSource.SelectParameters("OrderID").DefaultValue = FormView1.DataItem("OrderID") End Sub </script> <asp:FormView DataSourceID="OrdersDataSource"……> <ItemTemplate> <b>OrderID:</b> <asp:Label ID="OrderIDLabel" runat="server" Text='<%# Eval("OrderID") %>'></asp:Label><br /> …… <asp:GridView DataSourceID="OrderDetailsDataSource" ……> …… </asp:GridView> </ItemTemplate> </asp:FormView> <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:Northwind %>" ID="OrdersDataSource" runat="server" SelectCommand="SELECT [OrderID], [OrderDate], [ShipCity], [ShipCountry] FROM [Orders]"> </asp:SqlDataSource> <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:Northwind %>" ID="OrderDetailsDataSource" runat="server" SelectCommand="SELECT [Order Details].OrderID, Products.ProductName, [Order Details].UnitPrice, [Order Details].Quantity FROM [Order Details] INNER JOIN Products ON [Order Details].ProductID = Products.ProductID WHERE [Order Details].OrderID = @OrderID"> <SelectParameters> <asp:Parameter Name="OrderID" /> </SelectParameters> </asp:SqlDataSource> |
<script runat="server"> Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Dim s As SqlDataSource = e.Item.FindControl("OrderDetailsDataSource") s.SelectParameters("OrderID").DefaultValue = e.Item.DataItem("OrderID") End Sub </script> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者