根据下拉显示在asp.net GridView中的多个表 [英] according to dropdown show multiple tables in a gridview in asp.net

查看:63
本文介绍了根据下拉显示在asp.net GridView中的多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据下拉菜单,在asp.net的gridview中显示多个表

According to dropdown show multiple tables in a gridview in asp.net

推荐答案

将示例嵌入到2个表中

Herez the sample to embed 2 tables

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="True" DataKeyNames="pk_as_item_id">
<Columns>
<asp:BoundField ReadOnly="true" DataField="pk_as_item_id" HeaderText="ID" SortExpression="pk_as_item_id" />
<asp:BoundField DataField="description" HeaderText="Description" SortExpression="description" />
<asp:TemplateField HeaderText="Location" SortExpression="loca_description" >
<EditItemTemplate>
<asp:DropDownList ID="ddl_location" runat="server" DataSourceID="SqlDataSource2" DataValueField="pk_as_loca_id" DataTextField="loca_description" >
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbl_location" runat="server" Text='<%# Bind("loca_description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%


ConnectionStrings:个人%> " SelectCommand =" UpdateCommand =" < /asp:SqlDataSource > < asp:SqlDataSource ID =" runat 服务器" ConnectionString <%
ConnectionStrings:Personal %>" SelectCommand="SELECT [pk_as_item_id], [description], [fk_as_loca_id], [pk_as_loca_id], [loca_description] FROM [ITEMS], [LOCATIONS] WHERE [fk_as_loca_id] = [pk_as_loca_id]" UpdateCommand="UPDATE [ITEMS] SET [pk_as_item_id] = @pk_as_item_id, [description] = @description, [fk_as_loca_id] = ??????? WHERE [pk_as_item_id] = @pk_as_item_id"> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%


ConnectionStrings:个人%> " SelectCommand =" > < /asp:SqlDataSource >
ConnectionStrings:Personal %>" SelectCommand="SELECT [pk_as_loca_id], [loca_description] FROM [LOCATIONS]"> </asp:SqlDataSource>


这篇关于根据下拉显示在asp.net GridView中的多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆