Resolved Disable "Add New Record" Button when page loads

harlem98

Active member
Joined
Nov 4, 2021
Messages
27
Programming Experience
Beginner
My page has a comboBox which filters grid values. Im trying to disable grid's "add new record" button, when comboBox is empty, and enable the button when a value is selected and subconsequently, grid is loaded.

I have the following JavaScript function, which disables the button on pageLoad, but i cant enable the button later. What should i do?

C#:
function pageLoad() {
                       var grid = $find("<%=grid1.ClientID %>");
                       Button1 = $telerik.findControl(grid.get_element(), "AddNewRecordButton");
                       Button1.set_visible(false);
                   }

I tried to enable the button on the comboBox "SelectedChangeIndex", after trying in the PreRender method, with any results.

C#:
        if (radcombobox1.SelectedValue != null)
{
    GridCommandItem cmditem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];
    Telerik.Web.UI.RadButton addbtn = (Telerik.Web.UI.RadButton)cmditem.FindControl("AddNewRecordButton");
    addbtn.Visible = true;
}

else
{
    // alert
}

What is the best approach, server or even client side, to acchieve this goal?

EDIT: Solved!!

I did it server side using ItemDataBound event.
 
Last edited:
Back
Top Bottom