如何用设置gridview

我想用gridview做报表,实现像如下表格一样的效果:我该怎样设置gridview<tablewidth="526"height="187"border="1"><tr... 我想用gridview做报表,实现像如下表格一样的效果:我该怎样设置gridview
<table width="526" height="187" border="1">
<tr>
<td rowspan="2">名称</td>
<td height="38" colspan="2">成绩</td>
<td rowspan="2">总分</td>
</tr>
<tr>
<td height="23">数学</td>
<td>语文</td>
</tr>
<tr>
<td>zhangsan</td>
<td>90</td>
<td>89</td>
<td> </td>
</tr>
<tr>
<td>lisi</td>
<td>78</td>
<td>88</td>
<td> </td>
</tr>
</table>
我知道repeater能实现,不过我想知道用gridview怎么实现
这种效果是不是只能用table来实现,我觉得用table太麻烦了,几乎所有代码都得手写....
展开
 我来答
epldlnwynn
2009-04-02 · TA获得超过149个赞
知道小有建树答主
回答量:192
采纳率:0%
帮助的人:155万
展开全部

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>

    <style type="text/css">

        .head{border-left:1px solid #e8e8e8; text-align:center}

        .body{border-left:1px solid #f4f4f4; border-bottom:1px solid #f4f4f4}

        .input{border:1px solid #cccccc; width:80%;height:16px; padding-top:2px; padding-left:2px}

        .textarea{border:1px solid #cccccc; width:80%;height:60px; padding-top:1px; padding-left:1px; overflow-y:auto}

    </style>

</head>

<body>

    <form id="form1" runat="server">

    <div align="center">

        <div style="border:1px Solid #cccccc; width:700px">

            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Horiz Width="100%" BorderStyle="None" BorderWidth="0px" GridLines="None" UseAccessibleHeader="False" ShowFooter="True" Font-Size="12px" DataKeyNames="ID" CellPadding="0"     >

                <Columns>

                    <asp:TemplateField>

                        <HeaderTemplate>

                            <table border="0" cellpadding="0" cellspacing="0" style="margin:1px 1px 0px 1px" width="100%">

                                <tr>

                                    <td align="center" valign="middle" bgcolor="#f6f6f6" height="25" width="8%">编 号</td>

                                    <td class="head" valign="middle" bgcolor="#f6f6f6" width="50%">标 题</td>

                                    <td class="head" valign="middle" bgcolor="#f6f6f6" width="15%">添加时间</td>

                                    <td class="head" valign="middle" bgcolor="#f6f6f6" width="15%">管 理</td>

                                </tr>

                        </HeaderTemplate>

                        

                        <ItemTemplate>

                                <tr>

                                    <td style="border-bottom:1px solid #f4f4f4" align="center" valign="middle" height="20"><%# Eval("ID") %></td>

                                    <td align="left" class="body" valign="middle"> <%# Eval("Title") %></td>

                                    <td align="center" class="body" valign="middle"><%# Eval("AddTime") %></td>

                                    <td align="center" class="body" valign="middle">

                                        <asp:LinkButton ID="LinkButton1" CommandName="Edit" CausesValidation="false" runat="server">编 辑</asp:LinkButton> 

                                        <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" CausesValidation="false">删 除</asp:LinkButton></td>

                                </tr>

                        </ItemTemplate>

                        

                        <EditItemTemplate>

                        

                                <tr>

                                    <td rowspan="2" style="border-bottom:1px solid #f4f4f4; color:Red;" align="center" valign="middle" height="100">编辑状态</td>

                                    <td align="left" colspan="2" valign="middle" height="30"><asp:TextBox CssClass="input" ID="TextBox1" runat="server" Text='<%# Eval("Title") %>'></asp:TextBox></td>

                                    <td rowspan="2" align="center" class="body" valign="middle" height="100">

                                        <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Update" CausesValidation="true">更 新</asp:LinkButton> 

                                        <asp:LinkButton ID="LinkButton4" runat="server" CommandName="Cancel" CausesValidation="false">取 消</asp:LinkButton></td>

                                </tr>

                                <tr>

                                    <td height="70" colspan="2" class="body" valign="top"><asp:TextBox ID="TextBox2" runat="server" CssClass="textarea" TextMode="MultiLine" Text='<%# Eval("Content") %>'></asp:TextBox></td>

                                </tr>

                        </EditItemTemplate>

                        

                        <FooterTemplate>

                            </table>

                        </FooterTemplate>

                        

                    </asp:TemplateField>

                </Columns>

            </asp:GridView>

            <div style="font-size:12px; margin:3px" align="center">

                <asp:Label ID="Label1" runat="server"></asp:Label>

                <asp:Label ID="Label2" runat="server"></asp:Label>

                <asp:HyperLink ID="HyperLink1" runat="server">首 页</asp:HyperLink> 

                <asp:HyperLink ID="HyperLink2" runat="server">上一页</asp:HyperLink> 

                <asp:HyperLink ID="HyperLink3" runat="server">下一页</asp:HyperLink> 

                <asp:HyperLink ID="HyperLink4" runat="server">尾 页</asp:HyperLink>

            </div>

        </div>

    </div>

    </form>

</body>

</html>

程现方式如下图片

仵天菱C
2009-04-02 · TA获得超过233个赞
知道小有建树答主
回答量:173
采纳率:0%
帮助的人:180万
展开全部
不要用Girdview 空件,,用repeater

<table width="526" height="187" border="1">
<asp:Repeater ID ="repeater" DataSourceID ="你的数据源" runat ="server" >
<HeaderTemplate >
<tr>
<td rowspan="2">
名称
</td>
<td height="38" colspan="2">
成绩
</td>
<td rowspan="2">
总分
</td>
</tr>
<tr>
<td height="23">
数学
</td>
<td>
语文
</td>
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td>
<%#Eval ("字段名") %>
</td>
<td>
<%#Eval ("字段名") %>
</td>
<td>
<%#Eval ("字段名") %>
</td>
<td>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式