本文介绍了Gridview linkbutton oncommand不会更改C#中的按钮文本名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在尝试更改gidview oncommand事件中的按钮文本

我的aspx代码

Hi All

Am trying change the button text in gidview oncommand event

my aspx code

<asp:GridView ID="grdBindData" runat="server" CssClass="mGrid" AutoGenerateColumns="false" DataKeyNames="id, invoiceno"

                    EmptyDataText="NO DATA FOUND">
                    <Columns>
                    <asp:TemplateField HeaderText="SNO">
                          <ItemTemplate>
                          <%# Container.DataItemIndex + 1 %>
                          </ItemTemplate>
                          <ItemStyle HorizontalAlign="Center" Width="50px" />
                          </asp:TemplateField>
                    <asp:BoundField DataField="MR/MRS" HeaderText="MR/MRS" />
                     <asp:BoundField DataField="COMPANYNAME" HeaderText="COMPANYNAME" />
                     <asp:BoundField DataField="ADDRESS" HeaderText="ADDRESS" />
                     <asp:BoundField DataField="CONTACTNO" HeaderText="CONTACTNO" />
                    <asp:TemplateField HeaderText="INVOICENO">
                    <ItemTemplate>
                    <asp:LinkButton ID="LB1" runat="server" Text='<%#Eval("invoiceno")%>'

                            CommandArgument='<%#Bind("invoiceno")%>' oncommand="LB1_Command" CssClass="GrdLinkBtn"></asp:LinkButton>
                    </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="TRAVELDATE" HeaderText="TRAVELDATE" />
                    <asp:BoundField DataField="TOTALAMOUNT" HeaderText="TOTALAMOUNT" />
                    </Columns>

                    <HeaderStyle Font-Size="10px" ForeColor="Black" />

        </asp:GridView>



C#代码:



c# code:

protected void LB1_Command(object sender, CommandEventArgs e)
{
       btnsave.Text = "UPDATE"; // default text is Save to btnsave
}



该怎么做...
并以这种形式使用引导程序

我尝试过的事情:

我试图改变很多次,但我不能

帮帮我,谢谢



how to do that ...
and am using bootstrap in this form

What I have tried:

i tried to change many times but i can''t

help me thanks

推荐答案

<asp:GridView ID="grdBindData" runat="server" CssClass="mGrid" AutoGenerateColumns="false" DataKeyNames="id, invoiceno" EmptyDataText="NO DATA FOUND" OnRowCommand="grdBindData_RowCommand" >


在类似...的后面代码中添加事件.


Add the event in code behind like...

protected void grdBindData_RowCommand(object sender, GridViewCommandEventArgs e)
{
    btnsave.Text = "UPDATE";
}


这篇关于Gridview linkbutton oncommand不会更改C#中的按钮文本名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-17 16:33