Search code examples
c#asp.netradgridradcombobox

Disable RadComboBox (which is outside of RadGrid) when RadGrid has minimum 1 record (after insertion in Radgrid)


I have asp:FormView control in one of the Web page, inside which I am using Telrik RadGrid and RadComboBox(which is outside of RadGrid)

Consider this form as "Insert New records" form.

I can only insert records in RadGrid if any item has been selected from RadComboBox list, else RadGrid "Add New" button will be disabled if no item selected from RadComboBox. In other words, Insertion of records in RadGrid will take place only after user selects any item from RadComboBox.

Now I got a requirement that: If while adding any new records in this web form. User 1st selects any item from RadCmoboBox List and then click on RadGrid "Add New" button to add records, then after adding minimum 1 record in RadGrid, RadComboBox should disable (so that user should not select another item from RadComboBox)

i.e., Only 1 RadComboBox can have multiple RadGrid entries related to the selected item of RadGrid.

My issue is: since the Telerik controls are under asp FormView, so when I Add/Edit/Delete any record from RadGrid, page never post back.

In my case, page is not postback after page_load event. But after page load only, I can add records in RadGrid on selection of items from RadComboBox. 2nd time page is only posted back while selecting records from RadComboBox (on RadcomboBoxSelectedIndexChanged event)

I tried RadComboBox disabled code in all the events of RadGrid but it's not working because my page is not posted back after I Add/Edit/Delete records in RadGrid.


Solution

  • Found Solution myself: I disabled RadComboBox on RadComboBox_SelectedIndexChanged event and then allowed to add records in RadGrid (for the selected/disabled RadCombo Item).
    Then added a button next to RadComboBox, upon click, im deleting all records of RadGrid for particular/disabled RadCombo Item and enabling the RadCombo again to re-select the item. Its working fine.