<asp:GridView ID="gvInfo" runat="server" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" AutoGenerateColumns="False" DataKeyNames="lblUserID" OnRowDataBound="gvInfo_RowDataBound" OnRowDeleting="gvInfo_RowDeleting" OnRowEditing="gvInfo_RowEditing">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="用户编号">
<ItemStyle Width="250px" HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label runat="server" ID="lblUserID" Text = ""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="用户名称">
<ItemStyle Width="250px" HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label runat="server" ID="lblUserName" Text=""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField DeleteText="删除" ShowDeleteButton="True">
<ItemStyle HorizontalAlign="Center" Width="40px" />
</asp:CommandField>
</Columns>
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="用户编号">
<ItemStyle Width="250px" HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label runat="server" ID="lblUserID" Text = ""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="用户名称">
<ItemStyle Width="250px" HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label runat="server" ID="lblUserName" Text=""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField DeleteText="删除" ShowDeleteButton="True">
<ItemStyle HorizontalAlign="Center" Width="40px" />
</asp:CommandField>
</Columns>
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
解决方案 »
- “/”应用程序中的服务器错误。
- 如果清除页面缓存<%@ OutputCache Duration="600" VaryByParam="none" %>
- IIS服务器问题
- 为什么我的datagrid.pagecount总是0,我快疯了,整整弄了三天分页
- 为什么FreeTextBox在本地上可以运行,在服务器会不行
- dll控件不能下载的问题!!
- 请问谁知道怎么在REPORTING SERVICE做出2个Y坐标的图表来?
- .net 网站页面首次加载有错误,局部显示的方法?
- 请各位高手帮忙:代码有点问题;
- 急救﹐請問在WEB APPLICATION中如何調用API函數﹖
- 在asp.net(C#)中由服务器端导出excel到客户端,要求对excel的格式能进行详细的设置,请大家帮帮忙,帮小弟出点主意,看有没有什么好的方法,谢
- File控件如何能从客户端读取Excel文件内容
<ItemStyle Width="250px" HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label runat="server" ID="lblUserID" Text = '<%# Eval("字段名") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
所有的绑定需要用Eval来进行
参数为你在datasource里面查询得到的字段名
直接绑就可以了
<asp:TemplateField HeaderText="用户编号">
<ItemStyle Width="250px" HorizontalAlign="Left" />
<ItemTemplate>
<div><%# Eval("字段名") %>
</div> </ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="用户编号">
<ItemStyle Width="250px" HorizontalAlign="Left" />
<ItemTemplate>
<div><%# DataBinder.Eval(DataItem,"字段名") %>
</div> </ItemTemplate>
</asp:TemplateField>