C# Set Template Button Text On Gridview RowDataBound

tomraider

New Member
I have the following in my ASP.NET Grid\[code\] <asp:TemplateField HeaderText="Add/Remove" ShowHeader="False"> <ItemTemplate> <asp:Button ID="btnAddRemove" OnClick="updateRecords" runat="server" CausesValidation="false" CommandArgument='<%# Bind("id") %>' Text="Add" /> </ItemTemplate> <HeaderStyle BackColor="#BACBDD" /> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField>\[/code\]I need to set the button Text to Add or Remove based on a query result when the grid is loaded. I am calling the following method in the code behind when the grid is created but I am not sure how to access the button control and set the buttons text. I was able to modify the button text using Button(sender) on a click event but that is not working here.protected void grdToggleRowDataBound(object sender, GridViewRowEventArgs e)\[code\] { if (query result = xxx) button text == "Add" else button text == "Remove" }\[/code\]Any suggestions would be apprecieated?
 
Back
Top