2010-03-17 193 views
3

我綁定到ASP.NET GridView CommandField的皮膚。 一切工作正常,只是當我將CommandField屬性聲明從頁面移動到皮膚文件時,整個commandField屬性將被忽略。這裏是我的皮膚文件:ASP.NET CommandField和皮膚

<asp:GridView 
AllowPaging="true" 
AllowSorting="false" 
AutoGenerateEditButton="false" 
AutoGenerateDeleteButton="false" 
AutoGenerateSelectButton="false" 
AutoGenerateColumns="false" 
GridLines="None" 
PageSize="20" 
ShowFooter="false" 
ShowHeader="true" 
runat="server"> 
<Columns> 

<asp:CommandField 
ButtonType="Image" 
ControlStyle-Width="25" 
EditImageUrl="Images/Icons/pencil.png" 
DeleteImageUrl="Images/Icons/cross.png" 
/> 

</Columns> 
</asp:GridView> 

在web.config我只適用StyleSheetTheme。我想念什麼?

感謝

回答

1

這可以通過使用StyleSheetTheme和NOT Theme來實現。

下面是一個。皮膚文件

<asp:GridView runat="server" Font-Names="verdana,arial,sans serif" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" Width="95%"> 
<Columns> 
    <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Buttons/16x16/Cancel.gif" 
     EditImageUrl="~/Images/Buttons/16x16/Edit.gif" ShowEditButton="True" InsertImageUrl="~/Images/Buttons/16x16/New.gif" UpdateImageUrl="~/Images/Buttons/16x16/Update.gif" /> 

    <asp:CommandField ButtonType="Image" DeleteImageUrl="~/Images/Buttons/16x16/Delete.gif" 
     ShowDeleteButton="True" /> 
</Columns> 

<RowStyle Font-Size="Smaller" ForeColor="Black" /> 
<PagerStyle Font-Size="Smaller" ForeColor="Black" /> 
<SelectedRowStyle BackColor="Yellow" /> 
<HeaderStyle BackColor="#2D5C3D" Font-Size="Smaller" ForeColor="White" HorizontalAlign="left" /> 
<FooterStyle BackColor="#2D5C3D" /> 
<EditRowStyle BackColor="#2D5C3D" /> 
<AlternatingRowStyle BackColor="#ECE9D8" /> 

web.config文件定義了作爲樣式表裏站點級別定義的控件樣式

<pages styleSheetTheme="Green" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> 

包含在.aspx頁面GridView控件

<asp:GridView ID="gvUser" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="Id" onpageindexchanged="gvUser_PageIndexChanged" 
    onpageindexchanging="gvUser_PageIndexChanging" 
    onrowcancelingedit="gvUser_RowCancelingEdit" onrowdeleting="gvUser_RowDeleting" 
    onrowediting="gvUser_RowEditing" onrowupdating="gvUser_RowUpdating" 
    onselectedindexchanging="gvUser_SelectedIndexChanging" onsorted="gvUser_Sorted" 
    onsorting="gvUser_Sorting"> 

    <Columns> 
     <asp:BoundField DataField="Id" HeaderText="User Id" > 
     <HeaderStyle HorizontalAlign="Right" VerticalAlign="Middle" /> 
     <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" /> 
     </asp:BoundField> 


    </Columns> 
</asp:GridView> 

更多詳情請瀏覽以下

  1. http://weblogs.asp.net/vimodi/ThemesFaqs
  2. http://weblogs.asp.net/vimodi/WhatIs-StyleSheetTheme

希望這有助於!

-1

如果移動CommandField中標籤GridView的標籤之外,會發生什麼?

即:

<asp:GridView 
AllowPaging="true" 
AllowSorting="false" 
AutoGenerateEditButton="false" 
AutoGenerateDeleteButton="false" 
AutoGenerateSelectButton="false" 
AutoGenerateColumns="false" 
GridLines="None" 
PageSize="20" 
ShowFooter="false" 
ShowHeader="true" 
runat="server"> 
</asp:GridView> 

<asp:CommandField 
ButtonType="Image" 
ControlStyle-Width="25" 
EditImageUrl="Images/Icons/pencil.png" 
DeleteImageUrl="Images/Icons/cross.png" 
/> 
1

我得到:字面

<asp:CommandField 
ButtonType="Image" 
ShowDeleteButton="true" 
ItemStyle-Width="25" 
DeleteImageUrl="~/App_Themes/SimplaAdmin/Images/Icons/cross.png" 
/> 

內容皮膚文件中是不允許的。