求一段代码 DataGrid的第一列既是选择列又是序号列的代码

解决方案 »

  1.   

    就是一个选择列,选择列的text 显示为序号
      

  2.   

    只需要在你的Gridview的Databound中加上
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[1].Text = (e.Row.DataItemIndex + 1).ToString();
            }
      

  3.   

    <asp:TemplateField HeaderText="&lt;input type='checkbox' id='chk' name='chk' onclick='checkJs(this.checked);' /&gt;全选" FooterText="全选">
                                <ItemStyle HorizontalAlign="Center" Width="40px" />
                                <ItemTemplate>
                                    <input type="checkbox" id="checkboxname" name="checkboxname" value='<%# DataBinder.Eval(Container.DataItem, "appID")%>' onclick='SingleCheckJs();' />
                                </ItemTemplate>
                            </asp:TemplateField>