I have a RadGrid with GridEditCommandColumn inside ajaxToolkit:ModalPopupExtender panel. RadGrid is populated with asp ObjectDataSource, which has insert/update/delete methods triggered every time I click on a button in RadGrid ('Edit' button of the GridEditCommandColumn, for example). When an Update event is fired, all my controls inside the panel and including the panel itself are null, so I found a workaround and use RadGrid_ItemCommand function instead. This way I can set and validate my contols, and I can get an index in the grid and an event name fired.
My problem is that I have to use Request.Params to find changed Name on Edit, and this is not a good programming practice (even though it works). How can I replace Request.Params or at least set a name for the GridEditCommandColumn?
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
...
if (Request.Params["__EVENTTARGET"].Contains("UpdateButton"))
{
int index = e.Item.DataSetIndex;
int locationID = CurrentClub.Locations[index].LocationId;
ValidateUpdatedItem(locationID, Request.Params.Get(
"ctl00$ctl00$phBody$phBody$ucEditEventLoc$rgLocations$ctl00$ctl09$ctl00"));
}
else
if (Request.Params["__EVENTTARGET"].Contains("PerformInsertButton"))
ValidateNewItem(Request.Params.Get(
"ctl00$ctl00$phBody$phBody$ucEditEventLoc$rgLocations$ctl00$ctl02$ctl02$ctl00"));
}
----------------------------------- ascx page
<
telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="rgLocations">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rgLocations" />
<telerik:AjaxUpdatedControl ControlID="lblErrorMessage" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<ajaxToolkit:ModalPopupExtender ID="mdlPopupLocation" runat="server" PopupControlID="pnLocation"
BackgroundCssClass="modalBackground" TargetControlID="btnAddLocation">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel runat="server" ID="pnLocation" CssClass="pnlPop" Style="display: none;" EnableViewState="true">
<telerik:RadGrid ID="rgLocations" runat="server" GridLines="None" AllowPaging="True" AllowSorting="False" DataSourceID="objDSLocations" AutoGenerateColumns="False" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" HorizontalAlign="NotSet"
ShowStatusBar="false" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCommand="RadGrid1_ItemCommand">
<MasterTableView DataKeyNames="LocationId" CommandItemDisplay="Bottom" CommandItemSettings-RefreshImageUrl=""
CommandItemSettings-RefreshText="" GridLines="None" Width="100%" EditMode="InPlace">
<Columns>
<telerik:GridBoundColumn UniqueName="LocationName" EditFormColumnIndex="0" HeaderText="Location Name" DataField="Name"> </telerik:GridBoundColumn>
<telerik:GridEditCommandColumn UniqueName="editcmdColumnLoc">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn Text="Delete" CommandName="Delete" UniqueName= "DeleteColumn"></telerik:GridButtonColumn>
</Columns>
<ExpandCollapseColumn ButtonType="ImageButton" Visible="False" UniqueName="ExpandColumn">
<HeaderStyle Width="19px"></HeaderStyle>
</ExpandCollapseColumn>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>
<asp:ObjectDataSource ID="objDSLocations" runat="server" SelectMethod="SelectLocations"
InsertMethod="InsertLocations" UpdateMethod="UpdateLocations" TypeName="CHO.Next.WebUI.UserControls.Events.EditEventLocation">
<UpdateParameters>
<asp:Parameter Name="LocationId" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
Thank you