动态从库里面去了数据,结果发现除了生成表之外,还默认生成一个div,怎么操作其div,给他加样式表?

解决方案 »

  1.   

    本帖最后由 net_lover 于 2012-06-27 16:20:12 编辑
      

  2.   

    记录下div的id然后生成样式就好了咯。。 
    话说gridview的样式 是可以调整的啊- -  
      

  3.   


    关键是自动生成的div  没有Id ,格式就这样<div> 我是把它另存为html文件后看到的...
      

  4.   

    关键是自动生成的div 没有Id ,格式就这样<div> 我是把它另存为html文件后看到的,在<asp:gridview>源文件中看不到,所以没法操作...
      

  5.   

    你可以
    <div id=x>
    <asp:GridViewcss里面写
    #x div{}
    就可以了。
      

  6.   

    你要是特别纠结这个,就采用其他控件如ListView,Repeater
      

  7.   


    我根本就没打算让它生成div,如果他不生成,我就不用给他加样式了.....还有,我是帮人家改程序,asp我一点都没学过。别的更不会用..
      

  8.   

    那你无视他不就行了?多了个div外套对布局不会有影响吧??
      

  9.   

       <asp:GridView ID="GridView1" SkinID="GridView1" style="width:1500px;" DataKeyNames="zrzt" ShowHeader="false" runat="server" onrowdatabound="GridView1_RowDataBound">
              <RowStyle BackColor="#ECF5FF" ForeColor="Black" />
              <Columns>
                <asp:TemplateField >
                     <ItemTemplate>
                         <font color="#000000" style="font-size: 11px">
                           <%# Container.DataItemIndex + 1 %>
                         </font>
                     </ItemTemplate>
                     <ItemStyle Height="25px" Width="3%" HorizontalAlign="Center" />
                         <HeaderStyle Width="3%" Height="25px" HorizontalAlign="Center" />
                </asp:TemplateField>
    在asp文件查看,源码是上面这样的,在html文件查看,
     <div>主要在这) <table cellspacing="0" cellpadding="4" rules="all" border="1" id="GridView1" style="color:Black;background-color:White;border-color:#CCCCCC;border-width:1px;border-style:None;width:100%;border-collapse:collapse;width:1500px;">
    <tr onmouseover="currentcolor=this.style.backgroundColor;this.style.backgroundColor='#FFFF80',this.style.fontWeight='';" onmouseout="this.style.backgroundColor=currentcolor,this.style.fontWeight='';" onclick="this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';" style="color:Black;background-color:#ECF5FF;">
    <td align="center" style="height:25px;width:3%;">
                         <font color="#000000" style="font-size: 11px">
                           1
                         </font>
                     </td><td align="center" style="height:25px;width:6%;">
                         <font color="#000000" style="font-size: 11px">
                            发改委
                         </font>
                     </td>
      

  10.   

    没法控制和去掉的变通方法1<div id=x>
    <asp:GridViewcss里面写
    #x div{}
    就可以了。
    变通方法2
    换其他控件。
      

  11.   

    可以设法对你生成的div加点特别的,比如在加个div 标注id,这样不就好定义css了么
      

  12.   

    在你的GridView后面写JS试试控制它的样式,如Jquery可这样写:$("#GridView1").parent().css({border:"1px #ff0000 solid",padding:5});
      

  13.   

    这两天我也遇到这样的问题
    在网上搜索了一下,最简单的解决办法是把gridview的width属性设置为100%就行了