Hi all,
There does not seem to be a lot of info out there when using a GridView with AutoGenerateColumns="true".
In my scenario, I am attempting to use this because my GridView is dynamically pulling numeric values from a stored procedure.
I have everything looking great when viewing the data but now i need insert in the last column on the right a checkbox.
In my code below the checkbox is positioned between the column with the progressive number and the first auto-generated column.
Can you help me?
<asp:GridView ID="gvProducts"
runat="server"
DataKeyNames="ID"
EmptyDataText="KO"
EnableViewState="true"
CssClass="mGrid"
HorizontalAlign="Center"
OnRowDataBound="gvProducts_RowDataBound"
AutoGenerateColumns="true"
Width="100%">
<AlternatingRowStyle CssClass="altrows" />
<Columns>
<%--Col 1 --%>
<asp:TemplateField
HeaderText="N."
ItemStyle-CssClass="ddl_Class_new"
ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%#String.Format("{0:N0}",Container.DataItemIndex + 1)%>
</ItemTemplate>
</asp:TemplateField>
<%--Col 2 --%>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="chkRow" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>