我有一个gridview,它从数据库填充自动生成的列True.I有两列是asp:TemplateField列1,2。网格绑定4列。我可以在第5位使用一个templefield。我的意思是前2个asp:TemplateField然后是2列网格然后再是asp:TemplateField然后休息2列。
<asp:GridView ID="gvCycleStats" runat="server" HeaderStyle-CssClass="columnheaderLightBlue"
AlternatingRowStyle-CssClass="infoarea" Width="100%" AutoGenerateColumns="true"
AllowPaging="true" PageSize="20" OnPageIndexChanging="gvCycleStats_PageIndexChanged"
OnRowDataBound="gvCycleStats_OnRowDataBound" EmptyDataText="No work items to display."
EmptyDataRowStyle-CssClass="infoarea">
<RowStyle HorizontalAlign="Center" Wrap="false"></RowStyle>
<EmptyDataRowStyle CssClass="infoarea" />
<Columns>
<asp:TemplateField HeaderText="Details">
<ItemTemplate>
<img id="imgDetails" alt="Images" title="Click to view details" src="images/details-icon.gif"
onclick='<%# DataBinder.Eval(Container.DataItem, "ID", "javascript:return SetId(\"{0}\");")%> ' />
<%--<asp:LinkButton ID="lbSelect" runat="server" OnClientClick='<%# DataBinder.Eval(Container.DataItem, "ID", "javascript:return SetId(\"{0}\");")%>'Text="Select" />--%>
<%--OnClientClick="javascript:window.showModalDialog('ViewSelect.aspx?Id='" + id + " + "&windowTitle=" + " + windowtitle + " ', '', 'dialogHeight:700px;dialogWidth:1000px');return false;"/>--%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<HeaderTemplate>
DETAILS
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Details">
<ItemTemplate>
<img id="imgDetails" alt="Images" title="Click to view audit details" src="images/details-icon.gif" onclick='<%# DataBinder.Eval(Container.DataItem, "ID", "javascript:return SetAuditIdId(\"{0}\");")%> ' />
<%--<asp:LinkButton ID="lbSelect" runat="server" OnClientClick='<%# DataBinder.Eval(Container.DataItem, "ID", "javascript:return SetId(\"{0}\");")%>'Text="Select" />--%>
<%--OnClientClick="javascript:window.showModalDialog('ViewSelect.aspx?Id='" + id + " + "&windowTitle=" + " + windowtitle + " ', '', 'dialogHeight:700px;dialogWidth:1000px');return false;"/>--%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<HeaderTemplate>
AUDIT DETAILS
</HeaderTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="columnheaderLightBlue" />
<AlternatingRowStyle CssClass="infoarea" />
</asp:GridView>
答案 0 :(得分:0)
不要将其绑定为autogenerate columns = true,
这些列使用简单的绑定字段,然后使用模板字段