【发布时间】:2013-12-23 15:23:46
【问题描述】:
我有一种情况,我需要在 DropDownList 中显示 GridView 的列名,然后当用户在下拉列表中选择列名时,确定该列是数字还是字符串值。有谁知道我将如何做到这一点?我什至不知道从哪里开始。
如果有帮助,这里是我的 GridView 和 DataSource 的代码。
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" DataKeyNames="intBatchID"
AllowPaging="True" OnDataBound="GridView1_DataBound" OnRowDataBound="GridView1_RowDataBound"
AllowSorting="True" AutoGenerateColumns="False" SkinID="NOCTS"
BorderStyle="Solid" HeaderStyle-BackColor="#990033" Width="1000px"
DataSourceID="EntityDataSource1">
<HeaderStyle ForeColor="White"></HeaderStyle>
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="intBatchID" HeaderText="Batch ID" DataNavigateUrlFormatString="TestPage1.aspx?intBatchID={0}" DataTextField="intBatchID" />
<asp:BoundField DataField="vcharName" HeaderText="Name" ReadOnly="True"
SortExpression="vcharName" />
<asp:BoundField DataField="dtmScheduled" HeaderText="Date Scheduled"
ReadOnly="True" SortExpression="dtmScheduled" />
<asp:BoundField DataField="intBatchPriorityLevel"
HeaderText="Priority Level" ReadOnly="True"
SortExpression="intBatchPriorityLevel" />
</Columns>
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" PageButtonCount="4" PreviousPageText="Previous" NextPageText="Next" FirstPageText="First" LastPageText="Last" />
<PagerStyle HorizontalAlign="Center" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:EntityDataSource ID="EntityDataSource1" runat="server"
ConnectionString="name=TestEntities" DefaultContainerName="TestEntities"
EnableFlattening="False" EntitySetName="tbl_Batch"
Select="it.[intBatchID], it.[vcharName], it.[dtmScheduled], it.[intBatchPriorityLevel]"
OrderBy="it.[intBatchID]">
</asp:EntityDataSource>
【问题讨论】:
标签: c# asp.net gridview drop-down-menu