首页 > 开发 > CSS > 正文

css设定表格宽度

2024-07-21 02:16:38
字体:
来源:转载
供稿:网友
靠!
你真的不会css?那你先找一下css的资料吧。
比如你的css文件里面有以下内容:
class1{width:20%;}
class2{width:30%;}

然后写你的datagrid,你不要使用它默认的写法,将autogenrated(这个单词我忘了怎么拼了)设置为false,然后自己绑定到datagrid里面的模板里面,在每一项里面设置,老天,我刚才又看了一下你的贴子,这才明白,你只是使用的datagrid的原始功能呀?
看看下面的写法:
<asp:datagrid id="programmaticid" runat=server
   datasource='<%# databindingexpression %>'
   autogeneratecolumns="false"
   (other properties)>

   <columns>
      <asp:boundcolumn
         datafield="datasourcefield"
         dataformatstring="formatstring"
         footertext="footertext"
         headerimageurl="url"
         headertext="headertext"
         readonly="true|false"
         sortfield="datasourcefieldtosortby"
         visible="true|false"
         footerstyle-property="value"
         headerstyle-property="value"
         itemstyle-property="value"
      />

      <asp:buttoncolumn
         buttontype="linkbutton|pushbutton"
         command="bubbletext"
         datatextfield="datasourcefield"
         datatextformatstring="formatstring"
         footertext="footertext"
         headerimageurl="url"
         headertext="headertext"
         readonly="true|false"
         sortfield="datasourcefieldtosortby"
         text="buttoncaption"
         visible="true|false"
      />

      <asp:editcommandcolumn
         buttontype="linkbutton|pushbutton"
         canceltext="cancelbuttoncaption"
         edittext="editbuttoncaption"
         footertext="footertext"
         headerimageurl="url"
         headertext="headertext"
         readonly="true|false"
         sortfield="datasourcefieldtosortby"
         updatetext="updatebuttoncaption"
         visible="true|false"
        />

      <asp:hyperlinkcolumn
         datanavigateurlfield="datasourcefield"
         datanavigateurlformatstring="formatexpression"
         datatextfield="datasourcefield"
         datatextformatstring="formatexpression"
         footertext="footertext"
         headerimageurl="url"
         headertext="headertext"
         navigateurl="url"
         readonly="true|false"
         sortfield="datasourcefieldtosortby"
         target="window"
         text="hyperlinktext"
         visible="true|false"
       />

      <asp:templatecolumn>
         footertext="footertext"
         headerimageurl="url"
         headertext="headertext"
         readonly="true|false"
         sortfield="datasourcefieldtosortby"
         visible="true|false"
         <headertemplate>
             header template html
         </headertemplate >
         <itemtemplate>
             itemtemplate html
         </itemtemplate>
         <edititemtemplate>
             edititem template html
         </edititemtemplate>
         <footertemplate>
             footer template html
         </footertemplate>
      </asp:templatecolumn>
    </columns>
</asp:datagrid>
然后你可以为每一个模板指定一个cssclass了,或者直接在里面设置,就不必再使用css了。 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表