日期:2014-05-17  浏览次数:20601 次

格式化Gridview 求教
我还是学生,有好多还不明白,求教。。。

这是前台代码:
<%@ Page Language="C#" AutoEventWireup="true" EnableViewState="true" EnableEventValidation="false" CodeFile="ManageUser.aspx.cs" Inherits="Admin_ManageUser" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>无标题页</title>
</head>
<body>
  <form id="form1" runat="server">
  <asp:GridView ID="GridView1" runat="server">
  <Columns>
  <asp:HyperLinkField DataNavigateUrlFields="UserEmail" 
  DataNavigateUrlFormatString="mailto:{0}" DataTextField="UserEmail" />
  </Columns>
  </asp:GridView>
  <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
  DataKeyNames="UserID" onrowcommand="GridView2_RowCommand" 
  AllowSorting="True" BackColor="White" BorderColor="White" BorderStyle="Ridge" 
  BorderWidth="2px" CellPadding="3" CellSpacing="1" Font-Names="Andalus" 
  Font-Size="Medium" GridLines="None" HorizontalAlign="Center">
  <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
  <Columns>
   
  <asp:TemplateField HeaderText="用户名" SortExpression="UserName">
  <ItemTemplate>
  <asp:Label ID="Label1" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
  <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("UserName") %>'></asp:TextBox>
  </EditItemTemplate>
  </asp:TemplateField>
   
  <asp:TemplateField HeaderText="邮件地址">
  <ItemTemplate>
  <asp:HyperLink ID="HyperLink1" runat="server" 
  NavigateUrl='<%# Eval("UserEmail", "Mailto:{0}") %>' 
  Text='<%# Eval("UserEmail") %>'></asp:HyperLink>
  </ItemTemplate>
  </asp:TemplateField>
   
  <asp:TemplateField HeaderText="性别">
  <ItemTemplate >
  <%# Eval ("UserGender").ToString()=="1"?"男":"女" %>
  </ItemTemplate>
  </asp:TemplateField>
   
  <asp:TemplateField>
  <ItemTemplate >
  <asp:Button ID ="Button1" runat ="server" CausesValidation="false" CommandName="Del" Text="删除" OnClientClick="return confirm('确定删除吗?')" CommandArgument ='<%#Container.DataItemIndex %>' />
  <