嵌套Gridview中的额外行

时间:2013-02-05 09:06:55

标签: asp.net

我有使用itemtemplate列的gridview,它在渲染的html中生成额外的tr 我设置了CellPadding =“0”CellSpacing =“0”和AutoGenerateColumns =“false”,但是没有帮助..

这是我的gridview:

<asp:GridView ID="GridView1" GridLines="None" runat="server"
CellPadding="0" CellSpacing="0" ShowFooter="true"
AutoGenerateColumns="false" AllowPaging="true" OnPageIndexChanging="Grid_PageIndexChanging">
<Columns>

    <asp:TemplateField>
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="0" border="0" width="100%"
                class="table_sabcho">
        </HeaderTemplate>
        <ItemTemplate>

            <tr id="sds">
                <td><a href="show_item.aspx?id=<%# DataBinder.Eval (Container.DataItem, "id") %>">
                    <%# DataBinder.Eval(Container.DataItem, "number")%></a>
                </td>
                <td><%# DataBinder.Eval(Container.DataItem, "date","{0 :dd/MM/yyyy}")%>
                </td>

                <td><%# DataBinder.Eval(Container.DataItem, "Category")%></td>

                <td><%# DataBinder.Eval(Container.DataItem, "type_name")%>
                </td>
                <td style="padding-left: 0;"><%# getDoc((DataBinder.Eval(Container.DataItem, "id")).ToString())%>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate></table> </FooterTemplate>
    </asp:TemplateField>

</Columns>

这是我如何数据绑定网格:

protected void GetLastNewsGrid()
{

    String query = "Select  * from  sample_view order by id desc";
    DataSet lawdataset = SqlHelper.ExecuteDataset(connString, CommandType.Text, query);

    GridView1.DataSource = lawdataset;
    GridView1.DataBind();
}

这里呈现的是html:

<tr id="it is empty.." >
  <td></td>
</tr>
<tr id="sds" >
  <td><a href="show_item.aspx?id=518"> 4965/2/12 </a></td>
  <td>24.12.2012 </td>
  <td></td>
  <td>dep </td>
  <td style="padding-left: 0;"><a class="pdf_box" href="common/get_doc.aspx?docID=6900" ></a></td>
</tr>

0 个答案:

没有答案