【发布时间】:2013-03-20 04:41:27
【问题描述】:
我的 gridview 有一个从 aspx 设计器绑定的模板字段。我正在将数据表绑定到它。现在,我的模板字段(包含几个操作按钮)将作为第一列出现。有没有办法在模板字段之前排列数据表列?
GridView 的设计器代码:
<asp:GridView ID="JobListGrid" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField HeaderText="Actions">
<ItemTemplate>
<div>
<asp:ImageButton ID="View" CssClass="imgbutton" ToolTip="View Pdf" runat="server"
CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' ImageUrl="~/Content/pdf.PNG" CommandName="View" Width="36" Height="36" OnClientClick='<%# Eval("JobID", "OpenInNewWindow(\"{0}\").ToString()") %>' />
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
CS 代码:
JobListGrid.DataSource = dataTableObj;
JobListGrid.DataBind();
上面的代码显示了像这样的网格视图标题:
TemplateField | Col1 | Col2 | Col3
我需要将模板字段放在最后。 col1、col、col3 是从数据表中获取的。
【问题讨论】:
-
“将数据表添加到它”是什么意思?你能给我们举个例子,或者给我们看一些你试过的代码吗?
-
@Melanie,请检查更新后的问题。
标签: c# asp.net gridview aspxgridview