Hi...
I have an issue associated with RadCombo in the Gridtemplatecolumn of radGrid.
My scenario is:
I have a RadCombo inside the template column of RadGrid. When combo's selected item is changed then another column in Grid needs to be updated.
It should happen in such a way that when the column should get updated at the instance of itemchange, not after the user clicks update or any other mode.
Is there any way to access the selectedchange event of the Radcombo(combo being inside the template column)?
Or is there any work-around?
I need to arrive at a solution, could u provide me with one..
Please help me...
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| DataRowView v = (DataRowView)e.Item.DataItem; |
| ImageButton lnk = new ImageButton(); |
| lnk.ImageUrl = "~/Images/view.gif"; |
| lnk.ToolTip = GetString("TimeSheet"); |
| lnk.CommandArgument = "test"; |
| lnk.CommandName = "Redirect"; |
| lnk.Command += new CommandEventHandler(lnk_Command); |
| GridDataItem tem = e.Item as GridDataItem; |
| Item["Column"].Controls.AddAt(0, lnk); |
| } |
| } |
| protected void lnk_Command(object sender, CommandEventArgs e) |
| { |
| Session["Redirect"] = e.CommandArgument; |
| Response.Redirect("Timesheet.aspx"); |
| } |
When page is loaded first time ImageButton is successfully created and displayed in each row,
but clicking on it doesn't fire lnk_Command event (I have checked this adding breakpoints in lnk_Command),
Instead of redirecting I get the same page without ImageButtons displayed.
Please advice.
Please find the code snippet of webservice. [asmx page]
| [WebMethod(EnableSession = true)] |
| public List<AdminSettingsCategoryEntity> DeleteSelectedCategories(string strSelectedCateoryList, string modifiedBy, string clientID) |
| { |
| int intCatgIsUsed = 0; |
| int intCatgID = 0; |
| GridTableView CategoryGridMaterTableView = new GridTableView(); |
| System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); |
| var jsIds = serializer.Deserialize<Dictionary<string, object>>(strSelectedCateoryList); |
| if (jsIds != null) |
| { |
| ArrayList selectedItems = new ArrayList(); |
| foreach (KeyValuePair<string, object> keyValuePair in jsIds) |
| selectedItems.Add(long.Parse(keyValuePair.Key)); |
| if (selectedItems.Count > 0) |
| { |
| //Functionality to remove the selected Category IDS and updating list<bussinessEntity> |
| } |
| //return usersDraftList.ToList(); |
| } |
| return categoryList.ToList(); |
| } |
| <div id="divdgListOfCategory" runat="server" style="width: 420px; float: left; margin-bottom: 7px; |
| height: 180px;"> |
| <telerik:RadGrid ID="DgListOfCategory" runat="server" AutoGenerateColumns="false" AllowMultiRowSelection="true" AllowPaging="false" PagerStyle-Visible="false" |
| Skin="GridVista" EnableViewState="true" Width="412px" AllowMultiRowEdit="true" EnableEmbeddedSkins="false" |
| OnItemDataBound="DgListOfCategory_ItemDataBound" OnItemCommand="DgListOfCategory_ItemCommand"> |
| <MasterTableView Width="395px" AutoGenerateColumns="false" EditMode="InPlace" |
| NoMasterRecordsText="No Records Found" AllowAutomaticDeletes="True" DataKeyNames="ID" |
| AllowAutomaticInserts="false" AllowAutomaticUpdates="false" ShowHeadersWhenNoRecords="true" ClientDataKeyNames="ID,isUsed" |
| CommandItemDisplay="Top"> |
| <CommandItemTemplate> |
| <div id="lnkAddrows" style="float:left;line-height: 29px;"> |
| <asp:LinkButton ID="btnAddNewRecord" runat="server" CommandName="AddNewRecord" Style="vertical-align: bottom"> |
| <asp:Image ID="imgAdd" runat="server" ImageUrl="~/Images/AddRecord.gif" />Add New Record</asp:LinkButton> |
| </div> |
| <div id="divDeleteRows" style="float:left;line-height: 29px;padding-left:30px;"> |
| <asp:LinkButton ID="lnkDeleteRows" runat="server" Style="vertical-align: bottom" OnClientClick="javascript:return DgListOfCategoryDeleteSelectedRows()" > |
| <asp:Image ID="imgDelete" runat="server" ImageUrl="~/Images/val_close.png" /> Delete</asp:LinkButton> |
| </div> |
| </CommandItemTemplate> |
| <Columns> |
| <telerik:GridClientSelectColumn UniqueName="CheckboxSelectColumn" HeaderStyle-Width="40px" |
| ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" > |
| </telerik:GridClientSelectColumn> |
| <telerik:GridTemplateColumn UniqueName="Active" HeaderText="Select" DataType="System.Int32" |
| HeaderStyle-Width="40px" ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center"> |
| <ItemTemplate> |
| <asp:CheckBox ID="chkActive" runat="server" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn UniqueName="tempCatgName" HeaderText="Category Name" |
| DataType="System.String" ReadOnly="False" HeaderStyle-Width="160px" ItemStyle-Width="160px"> |
| <ItemTemplate> |
| <telerik:RadTextBox ID="CategoryName" Text='<%#Eval("CategoryName") %>' runat="server" |
| EmptyMessage="Category Name" MaxLength="50" Width="145px"> |
| </telerik:RadTextBox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="True" AllowSorting="false" |
| Visible="false" ItemStyle-Width="0" HeaderStyle-Width="0" UniqueName="ID"> |
| <HeaderStyle ForeColor="Silver" /> |
| <ItemStyle ForeColor="Silver" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="isUsed" HeaderText="isUsed" ItemStyle-Width="5" |
| HeaderStyle-Width="5" Visible="false" UniqueName="isUsed"> |
| </telerik:GridBoundColumn> |
| <telerik:GridClientDeleteColumn HeaderStyle-Width="40px" ButtonType="ImageButton" HeaderText="Delete" |
| CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" > |
| <HeaderStyle Width="40px" /> |
| <ItemStyle HorizontalAlign="Center" Width="30px" /> |
| </telerik:GridClientDeleteColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="174px"> |
| </Scrolling> |
| <Selecting AllowRowSelect="true" /> |
| <ClientEvents OnRowSelected="DgListOfCategory_RowSelected" OnRowCreated="DgListOfCategory_RowCreated" |
| OnRowDeselected="DgListOfCategory_RowDeselected" OnRowDeleted="DgListOfCategory_RowDeleted" /> |
| <DataBinding Location="CategoryPopUp.aspx" SelectCountMethod="MyFirstPageMethod"/> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </div> |
| <script src="../../JavaScripts/jquery-1.3.2.min.js" type="text/javascript"></script> |
| <script src="../../JavaScripts/json2.js" type="text/javascript"></script> |
| <script src="../../JavaScripts/jquery-1.2.6.pack.js" type="text/javascript"></script> |
| <script type="text/javascript" language="javascript"> |
| var commandName = ""; |
| var tableView = null; |
| var clientIDValue = null; |
| var SelectedCatgIDs = null |
| var selected = {}; |
| var userIDValue = null; |
| function DgListOfCategory_RowSelected(sender, args) { |
| var mailID = args.getDataKeyValue("ID"); |
| if (!selected[mailID]) { |
| selected[mailID] = true; |
| } |
| // Set the value of the hidden variable to |
| // the value of the javascript variable |
| var hiddenControl = '<%= selectedInstrumentIds.ClientID %>'; |
| document.getElementById(hiddenControl).value = Sys.Serialization.JavaScriptSerializer.serialize(selected); |
| } |
| function DgListOfCategory_RowDeselected(sender, args) { |
| var mailID = args.getDataKeyValue("ID"); |
| if (selected[mailID]) { |
| selected[mailID] = null; |
| } |
| // Set the value of the hidden variable to |
| // the value of the javascript variable |
| var hiddenControl = '<%= selectedInstrumentIds.ClientID %>'; |
| document.getElementById(hiddenControl).value = Sys.Serialization.JavaScriptSerializer.serialize(selected); |
| } |
| function DgListOfCategory_RowCreated(sender, args) { |
| var mailID = args.getDataKeyValue("ID"); |
| if (selected[mailID]) { |
| args.get_gridDataItem().set_selected(true); |
| } |
| } |
| function DgListOfCategory_RowDeleted(sender, args) |
| { |
| alert("Delete Cliecked"); |
| var mailID = args.getDataKeyValue("ID"); |
| if (!selected[mailID]) { |
| selected[mailID] = true; |
| } |
| // Set the value of the hidden variable to |
| // the value of the javascript variable |
| var hiddenControl = '<%= selectedInstrumentIds.ClientID %>'; |
| document.getElementById(hiddenControl).value = Sys.Serialization.JavaScriptSerializer.serialize(selected); |
| } |
| function DgListOfCategoryDeleteSelectedRows() |
| { |
| tableView = $find("<%= DgListOfCategory.ClientID %>").get_masterTableView(); |
| clientIDValue = document.getElementById("ctl00_plhMainContentArea_hdnClientID").value; |
| userIDValue = document.getElementById("ctl00_plhMainContentArea_hdnUserID").value; |
| SelectedCatgIDs = document.getElementById("ctl00_plhMainContentArea_selectedInstrumentIds").value; |
| var DataItems = $find("<%=DgListOfCategory.ClientID %>").get_masterTableView().get_dataItems(); |
| if(DataItems != null) |
| { |
| executeMethod("../../WebServices/SettingsWebService.asmx", "DeleteSelectedCategories", getRequestData(tableView), updateGrid); |
| } |
| } |
| function updateGrid(result) |
| { |
| tableView.set_dataSource(result.d); |
| tableView.dataBind(); |
| } |
| function getRequestData(tableView) { |
| return JSON.stringify({ |
| "strSelectedCateoryList": SelectedCatgIDs, |
| "modifiedBy" : userIDValue, |
| "clientID" : clientIDValue |
| }); |
| } |
| function executeMethod(location, methodName, methodArguments, onSuccess, onFail) |
| { |
| $.ajax({ |
| type: "POST", |
| url: location + "/" + methodName, |
| data: methodArguments, |
| contentType: "application/json; charset=utf-8", |
| dataType: "json", |
| success: onSuccess, |
| fail: onFail |
| }); |
| } |
| </script> |
| var dataItem = oExplorer.get_grid().get_masterTableView().get_selectedItems()[0].get_dataItem(); |
| var status = dataItem.Attributes["Status"]; |
| if (selectedItem.get_type() == Telerik.Web.UI.FileExplorerItemType.File) { |
| alert('How do I get the Attributes here?'); |
| } |
