css設(shè)定表格寬度
2024-07-21 02:16:38
供稿:網(wǎng)友
靠!
你真的不會css?那你先找一下css的資料吧。
比如你的css文件里面有以下內(nèi)容:
class1{width:20%;}
class2{width:30%;}
然后寫你的datagrid,你不要使用它默認(rèn)的寫法,將autogenrated(這個(gè)單詞我忘了怎么拼了)設(shè)置為false,然后自己綁定到datagrid里面的模板里面,在每一項(xiàng)里面設(shè)置,老天,我剛才又看了一下你的貼子,這才明白,你只是使用的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>
然后你可以為每一個(gè)模板指定一個(gè)cssclass了,或者直接在里面設(shè)置,就不必再使用css了。