gpt4 book ai didi

asp.net - 如何将单独的查询绑定(bind)到 GridView Asp.net C# 中的单独列

转载 作者:行者123 更新时间:2023-12-01 03:42:50 24 4
gpt4 key购买 nike

我正在开发与 Oracle 10.2.0.4 集成的 ASP.net 4.0

这是我的 GridView 及其 SqlDatasource 代码

<asp:GridView ID="gvRegNumber" runat="server" AutoGenerateColumns="False" DataSourceID="DsRegNumberGrid"
Width="100%" AllowPaging="True" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellSpacing="2" ForeColor="Black" PageSize="3"
CssClass="mGrid" onrowcommand="gvRegNumber_RowCommand" >
<Columns>
<asp:BoundField DataField="Registration No." HeaderText="Registration No." SortExpression="Registration No." />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Make" HeaderText="Make" SortExpression="Make" />
<asp:BoundField DataField="Model" HeaderText="Model" SortExpression="Model" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="From Date" HeaderText="From Date" SortExpression="From Date" />
<asp:BoundField DataField="To Date" HeaderText="To Date" SortExpression="To Date" />
<asp:TemplateField>
<EditItemTemplate>
<asp:ImageButton ID="imgbtnUpdate" CommandName="Update" runat="server" ImageUrl="~/Themes/Icons/edit_icon.png"
ToolTip="Update" Height="20px" Width="20px" />
</EditItemTemplate>
<HeaderTemplate>
<asp:Label ID="Edit" Text="Edit" runat="server"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="EditRow" CssClass="mGrid-edit" ImageUrl="~/Themes/Icons/edit_icon.png"
runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Delete" Text="Edit" runat="server"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="DeleteRow" CssClass="mGrid-delete" ImageUrl="~/Themes/Icons/delete_icon.png"
runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

</asp:GridView>
<asp:SqlDataSource ID="DsRegNumberGrid" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT &quot;fkEnumerationId&quot; AS &quot;Registration No.&quot;, &quot;Text&quot; AS &quot;Name&quot;, &quot;AdditionalValueText&quot; AS &quot;Make&quot;, &quot;AdditionalValue&quot; AS &quot;Model&quot;, &quot;IsActive&quot; AS &quot;Status&quot;, &quot;CreatedOn&quot; AS &quot;From Date&quot;, &quot;LastUpdatedOn&quot; AS &quot

;To Date&quot; FROM &quot;EnumerationValue&quot;">
</asp:SqlDataSource>

我只想为我的网格中的单独列设置单独的数据源。那可能吗?如果是,怎么办?

提前致谢。

最佳答案

您可以在您的 SP 中执行此操作

select en1.text as 'Country', en2.text as 'City',en3.text as 'Region'  from
EnumValue en1, EnumValue en2, EnumValue en3
where en1.id = en2.[fkEnumeration] and en3.[fkEnumeration] = en2.id and
en1.id='yourid' ;

关于asp.net - 如何将单独的查询绑定(bind)到 GridView Asp.net C# 中的单独列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23284700/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com