質問

ASP.NET GridView CommandField のスキンに関連付けています。すべて正常に動作していますが、CommandField プロパティの宣言をページからスキン ファイルに移動すると、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 のみを適用します。何か見逃しているでしょうか?

ありがとう

役に立ちましたか?

解決

これは、テーマではなく、StyleSheetTheme を使用することで実現できます。

以下は、.skin ファイルで定義されているコントロール スタイルです。

<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 ファイルは、StyleSheetTheme をサイト レベルとして定義します。

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

GridView コントロールを含む .aspx ページ

    <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

お役に立てれば!

他のヒント

私が入手ます:

リテラルのコンテンツ

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

スキンファイル内で許可されていません。

を使用したい場合は、 すばらしい アイコンを次のように変更できます。

<asp:CommandField ButtonType="Link" ShowEditButton="true"
EditText="<i class='fas fa-edit'></i>" />

削除の場合は次のように使用します。

DeleteText="<i class='fas fa-trash-alt'></i>"

カネル用:

CancelText="<i class='fas fa-window-close'></i>"

アップデートで使用する場合:

UpdateText="<i class='fas fa-sync'></i>"
あなたはGridViewのタグの外に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"> 
</asp:GridView> 

<asp:CommandField 
ButtonType="Image" 
ControlStyle-Width="25" 
EditImageUrl="Images/Icons/pencil.png" 
DeleteImageUrl="Images/Icons/cross.png" 
/> 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top