There is a RadComboBox (outside of RadGrid) and a RadGrid in my Web page.
When first time page loads, and user forgets to Select Item from RadComboBox (which is outside of RadGrid) and clicks on "Add New" button of RadGrid then this button should disable at that time and an alert should come ('Select item from RadComboBox first')
Now, when user select the item from RadComboBox, and then click on "Add New" button of RadGrid then it should perform "add" functionality //---this part is done
Below code is working fine only to disable the "Add New" button and show alert.
GridCommandItem cmditem = (GridCommandItem)RGGSTAcCode.MasterTableView.GetItems(GridItemType.CommandItem)[0];
System.Web.UI.WebControls.Button ctrl = (System.Web.UI.WebControls.Button)cmditem.FindControl(
"AddNewRecordButton"
);
ctrl.Enabled =
false
;
ctrl.Attributes.Add(
"onClick"
,
"test()"
);
System.Web.UI.WebControls.LinkButton btn = (System.Web.UI.WebControls.LinkButton)cmditem.FindControl(
"InitInsertButton"
);
btn.Enabled =
false
;
btn.Attributes.Add(
"onClick"
,
"test()"
);
But how to create this whole requirement using above code? Where to put this line of code, in which event, so that it should work as per need.
Below is the whole HTML code I am using currently:
<
telerik:RadComboBox
ID
=
"ddlCompany"
runat
=
"server"
Height
=
"200"
Width
=
"240"
DropDownWidth
=
"310"
EmptyMessage
=
"- Select Product -"
HighlightTemplatedItems
=
"true"
CausesValidation
=
"false"
Filter
=
"StartsWith"
AppendDataBoundItems
=
"true"
AllowCustomText
=
"true"
AutoPostBack
=
"true"
DataTextField
=
"Title"
DataValueField
=
"Code"
OnSelectedIndexChanged
=
"ddlCompany_SelectedIndexChanged"
>
</
telerik:RadComboBox
>
<
br
/>
<
br
/>
<
telerik:RadGrid
ID
=
"RGGSTAcCode"
runat
=
"server"
ShowFooter
=
"True"
GroupingEnabled
=
"False"
ShowStatusBar
=
"true"
EmptyDataText
=
"No record available."
AllowAutomaticInserts
=
"False"
AllowAutomaticUpdates
=
"False"
AllowAutomaticDeletes
=
"true"
OnNeedDataSource
=
"RGGSTAcCode_NeedDataSource"
OnItemDataBound
=
"RGGSTAcCode_ItemDataBound"
OnInsertCommand
=
"RGGSTAcCode_InsertCommand"
OnDeleteCommand
=
"RGGSTAcCode_DeleteCommand"
OnUpdateCommand
=
"RGGSTAcCode_UpdateCommand"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
mastertableview
ShowHeadersWhenNoRecords
=
"true"
autogeneratecolumns
=
"false"
datakeynames
=
"AccountCodeID"
InsertItemDisplay
=
"Top"
insertitempageindexaction
=
"ShowItemOnCurrentPage"
ShowFooter
=
"True"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn"
></
telerik:GridEditCommandColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"AccountCode"
HeaderText
=
"Account Code"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblAcCode"
Text='<%# Eval("AccountCode") %>' runat="server"></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"ddlAcCode"
DataTextField
=
"AccountDescription"
DataValueField
=
"AccountCodeID"
runat
=
"server"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"AccountDescription"
HeaderText
=
"Description"
UniqueName
=
"AccountDescription"
SortExpression
=
"AccountDescription"
InsertVisiblityMode
=
"AlwaysHidden"
ReadOnly
=
"true"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
aggregate
=
"SUM"
DataField
=
"Amount"
HeaderText
=
"Amount"
FooterText
=
"Total : "
UniqueName
=
"Amount"
SortExpression
=
"Amount"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Remark"
HeaderText
=
"IFCA Remark"
UniqueName
=
"Remark"
SortExpression
=
"Remark"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
ConfirmTextFormatString
=
"Are you sure you want to Delete {0} Account Code?"
ConfirmTextFields
=
"AccountCodeID"
ConfirmDialogType
=
"RadWindow"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
></
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
ButtonType
=
"ImageButton"
/>
</
EditFormSettings
>
<
CommandItemSettings
AddNewRecordText
=
"Add new record"
RefreshText
=
"Refresh"
></
CommandItemSettings
>
</
mastertableview
>
</
telerik:RadGrid
>
Please guide.
Please note that I am very new in Telerik controls so if I ask something very basic please forgive and try to guide me in a simple way.