C# ASP.NET Gridview自定义命令字段,可切换到编辑模式,并可在rowdatabound中捕获某些差异

C# ASP.NET Gridview自定义命令字段,可切换到编辑模式,并可在rowdatabound中捕获某些差异,c#,asp.net,gridview,rowdatabound,C#,Asp.net,Gridview,Rowdatabound,我第一个关于Stackoverflow的问题 ASP.NET C#Gridview 我的问题是 如何在命令字段模板中使用自定义编辑按钮,该按钮仍将行切换到编辑模式,但将在其中一个字段中显示不同的内容 我的命令列有一个模板字段。 我使用rowdatabound事件作为逻辑 <asp:templatefield itemstyle-width="300px"> <itemtemplate> <asp:Literal ID="label2" ru

我第一个关于Stackoverflow的问题

ASP.NET C#Gridview

我的问题是

如何在命令字段模板中使用自定义编辑按钮,该按钮仍将行切换到编辑模式,但将在其中一个字段中显示不同的内容

我的命令列有一个模板字段。 我使用rowdatabound事件作为逻辑

 <asp:templatefield itemstyle-width="300px">
    <itemtemplate>
        <asp:Literal ID="label2" runat="server" Text='<%# System.Net.WebUtility.HtmlDecode(Eval("translation").ToString()) %>'></asp:Literal>
    </itemtemplate>
    <edititemtemplate>
        <cc1:myeditor ID="teHtml" startupInSourceOrwysiwyg="wysiwyg" type="lite" EnableViewState="false" runat="server" Text='<%# Bind("translation")%>' />
    </edititemtemplate>
</asp:templatefield>
    <asp:templatefield headertext="Command">
    <itemtemplate>
        <asp:LinkButton CommandName="Edit" Text="Edit" ID="btnEdit" runat="server"></asp:LinkButton>
        <asp:LinkButton CommandName="EditHtml" Text="EditHtml" ID="btnEditHtml" runat="server" ></asp:LinkButton>
    </itemtemplate>
    <edititemtemplate>
        <asp:LinkButton CommandName="Update" Text="Update" ID="btnUpdate" runat="server"></asp:LinkButton>
        <asp:LinkButton CommandName="Cancel" Text="Cancel" ID="btnCancel" runat="server"></asp:LinkButton>
    </edititemtemplate>
</asp:templatefield>

谢谢

为这个字段定义编辑模板怎么样?你是说EditItemTemplate吗?不同的内容是什么意思?@user3443090,确切地说是Andrei-我已经添加了模板字段代码
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
        {
            CkEditor editorInstance = (CkEditor)e.Row.FindControl("teHtml");

            string theTranslationText = editorInstance.Text;
            bool isHtmlModeSelected;

            isHtmlModeSelected = hfHtml.Value == "true" ? true : false;

            if (!(isHtmlModeSelected) || (someHtmlFoundInTranslation(theTranslationText)))
            {
                editorInstance.startupInSourceOrwysiwyg = "source";
                editorInstance.removeplugins = "toolbar";
            }
        }
    }