日期:2013-10-09  浏览次数:20548 次

靠!
你真的不会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:Hyper