This is a migrated thread and some comments may be shown as answers.
Could not enable/disable radbutton in RadGrid control
1 Answer 18 Views
This is a migrated thread and some comments may be shown as answers.
R
Top achievements
Rank 1
R asked on 15 Feb 2014, 02:20 AM
Hi,

I have a problem in enable/disable RadButton in RadGrid control below is my code snippet. 

binding is not working as expected.

design:
<telerik:GridTemplateColumn HeaderText="Print" ItemStyle-Width="80px" UniqueName="PrintUN">
                            <ItemTemplate>
                                <telerik:RadButton runat="server" ID="btnPrintTicket" Text="Print Tickets" CommandArgument  ='<%# DataBinder.Eval(Container.DataItem, "ID")%>' CommandName="Print" Enabled="false"></telerik:RadButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>

code behind:
protected void rgd_ItemDataBound(object sender, GridItemEventArgs e)
        {
            List<User_MyRegistration> lstResult = b.GetRegistrationsForUser(UserSessionClass.UserName);

            if (e.Item is GridDataItem)
            {
                GridDataItem item =(GridDataItem) e.Item;
                RadButton btnPrint = (RadButton)item.FindControl("btnPrintTicket");

                if (lstResult.Count > 0)
                {
                    foreach (User_MyRegistration userReg in lstResult)
                    {
                        if (userReg.Status == "Yes")
                        {
                            btnPrint.Enabled = true;
                        }
                    }
                }
            }
        }









1 Answer, 1 is accepted

Sort by
0
R
Top achievements
Rank 1
answered on 16 Feb 2014, 02:31 AM
Hi,

resolved the issues by below code snippet

if (e.Item is GridDataItem)
            {
                GridDataItem item =(GridDataItem) e.Item;
                Label lblAStatus = (Label)item.FindControl("lblStatus");
                RadButton btnPrint = (RadButton)item.FindControl("btnPrintTicket");

                if (lstResult.Count > 0)
                {
                    if (lblAStatus.Text == "Yes")
                    {
                        btnPrint.Enabled = true;
                    }
                }
            }
Asked by
R
Top achievements
Rank 1
Answers by
R
Top achievements
Rank 1
Share this question
or