Aktivieren Linkbutton in Gridview, wenn ASP.NET Button Geklickt

Ich habe ein gridview, zeigt eine Schallplatte, die einige linkbuttons.

Was ich will, ist, wenn meine ASP.NET ButtonStart geklickt wird, aktivieren Sie das LinkButton-in der Gridview -

<asp:GridView ID="gvData" runat="server" CellPadding="4" ForeColor="#333333"
 GridLines="None" Width="688px" AllowPaging="True" AllowSorting="True"AutoGenerateColumns="False"
OnRowCommand="gvData_RowCommand" 
OnRowDataBound="gvData_RowDataBound">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
      <asp:BoundField DataField="Id" HeaderText="ID" SortExpression="Id">
         <ItemStyle HorizontalAlign="Center" />
      </asp:BoundField>                        
     <asp:BoundField DataField="Received" HeaderText="Received" SortExpression="Received"
        ReadOnly="true">
       <ItemStyle HorizontalAlign="Center" />
      </asp:BoundField>                                             
     <asp:TemplateField ShowHeader="False">
     <ItemTemplate>
          <asp:LinkButton ID="lbClose" runat="server" CausesValidation="False"      CommandName="CloseClicked" 
          OnClick="CloseClick_Click">Close</asp:LinkButton>                                                             
     </ItemTemplate>                            
      <FooterStyle HorizontalAlign="Center" />
     <ItemStyle HorizontalAlign="Center" />
  </asp:TemplateField>
  </Columns>                   
  </asp:GridView>


  <asp:button runat="server" text="Start" ID="btnStart" />

Ich wissen, wie man deaktivieren, es im RowDataBound.

protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
    {


        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton lbClose = (LinkButton)e.Row.Cells[5].FindControl("lbClose");

            if (lbClose == null)
            {
                return;
            }


            var lblReceive = (Label)e.Row.FindControl("lblReceive ");               


            if (lblReceive .Text == "" && !IsPostBack)
            {
                lbClose.Enabled = true;
                lbEdit.Enabled = true;
                lbDelete.Enabled = true;
            }

        }
  }

Ich glaube, Sie haben zu nennen RowDataBound aus dem BtnStart Click-Ereignis, bin aber nicht sicher.

protected void btnStartTrans_Click(object sender, EventArgs e)
{
      //Enable lblClose in gridview
}
  • In der Schaltfläche click-Ereignis, finden, Kontrolle der lbclose und stellen Sie seine visible=true.
InformationsquelleAutor Apollo | 2013-08-20
Schreibe einen Kommentar