or
| <%@ Control Language="C#" AutoEventWireup="true" CodeFile="CmlDetailsGrid.ascx.cs" |
| Inherits="UserControls_CmlDetailsGrid" %> |
| <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
| <link href="../Styles/Styles.css" rel="stylesheet" type="text/css" /> |
| <telerik:RadAjaxManagerProxy ID="RadAjaxManager_DetailsGrid" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadGrid_CMLDetails"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadGrid_CMLDetails" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManagerProxy> |
| <script type="text/javascript"> |
| function setFocus(caller, up, down, left, right) { |
| //alert(caller + ' ~ ' + up + ' ~ ' + down + ' ~ ' + left + ' ~ ' + right); |
| var keynum; |
| if (window.event) // IE |
| { |
| keynum = window.event.keyCode; |
| } |
| else if (e.which) // Netscape/Firefox/Opera |
| { |
| keynum = window.event.which; |
| } |
| if (keynum == 38 && up != "noControl") { |
| var control = $get(up); |
| control.focus(); |
| } |
| else if (keynum == 40 && down != "noControl") { |
| var control = $get(down); |
| control.focus(); |
| } |
| else if (keynum == 37 && left != "noControl") { |
| var control = $get(left); |
| control.focus(); |
| } |
| else if (keynum == 39 && right != "noControl") { |
| var control = $get(right); |
| control.focus(); |
| } |
| } |
| </script> |
| <div id="CMLDetailsGrid" style="height: 100%; width: 100%;"> |
| <telerik:RadGrid ID="RadGrid_CMLDetails" runat="server" AllowSorting="True" Height="100%" |
| Width="100%" AutoGenerateColumns="False" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" |
| OnPreRender="RadGrid_CMLDetails_PreRender"> |
| <MasterTableView TableLayout="Fixed" EditMode="InPlace" DataKeyNames="cmlId" ItemStyle-Height="10px"> |
| <HeaderStyle Wrap="false" Width="110px" HorizontalAlign="Center" /> |
| <Columns> |
| <telerik:GridBoundColumn DataField="cmlId" DataType="System.Int64" HeaderText="CML Id" |
| SortExpression="cmlId" UniqueName="CML_ID" DataFormatString="<nobr>{0}</nobr>" |
| Visible="false" /> |
| <telerik:GridBoundColumn DataField="partNum" DataType="System.String" HeaderText="Part #" |
| SortExpression="partNum" UniqueName="partNum" DataFormatString="<nobr>{0}</nobr>" |
| AutoPostBackOnFilter="true" /> |
| <telerik:GridBoundColumn DataField="cumPct" DataType="System.Int64" HeaderText="Cum%" |
| SortExpression="cumPct" UniqueName="cumPct" DataFormatString="<nobr>{0}</nobr>" |
| AutoPostBackOnFilter="true" /> |
| <telerik:GridBoundColumn DataField="extCost" DataType="System.Int64" HeaderText="Ext Cost" |
| SortExpression="extCost" UniqueName="extCost" DataFormatString="<nobr>{0}</nobr>" |
| AutoPostBackOnFilter="true" /> |
| <telerik:GridBoundColumn DataField="totalQty" DataType="System.Int64" HeaderText="Total Qty" |
| SortExpression="totalQty" UniqueName="totalQty" DataFormatString="<nobr>{0}</nobr>" |
| AutoPostBackOnFilter="true" /> |
| <telerik:GridBoundColumn DataField="moe" DataType="System.String" HeaderText="MOE" |
| SortExpression="moe" UniqueName="moe" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="source" DataType="System.String" HeaderText="Source" |
| SortExpression="source" UniqueName="source" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="structureQty" DataType="System.Int64" HeaderText="Part Req Qty" |
| SortExpression="structureQty" UniqueName="structureQty" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="unitPrice" DataType="System.Int64" HeaderText="Unit Price" |
| SortExpression="unitPrice" UniqueName="unitPrice" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="nre" DataType="System.Int64" HeaderText="NRE" |
| SortExpression="nre" UniqueName="nre" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="nreDesc" DataType="System.String" HeaderText="NRE Desc" |
| SortExpression="nreDesc" UniqueName="nreDesc" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridTemplateColumn DataField="arQty" DataType="System.Int64" |
| HeaderText="AR Qty" SortExpression="arQty" UniqueName="gtcArQty"> |
| <ItemTemplate> |
| <asp:TextBox runat="server" ID="txtArQty" Text='<%# DataBinder.Eval(Container.DataItem,"arQty") %>' |
| AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn DataField="minBuyQty" DataType="System.Int64" |
| HeaderText="MB Qty" SortExpression="minBuyQty" UniqueName="minBuyQty"> |
| <ItemTemplate> |
| <asp:TextBox runat="server" ID="txtMinBuyQty" Text='<%# DataBinder.Eval(Container.DataItem,"minBuyQty") %>' |
| AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn DataField="shrinkagePct" DataType="System.Int64" |
| HeaderText="Shrk %" SortExpression="shrinkagePct" UniqueName="shrinkagePct"> |
| <ItemTemplate> |
| <asp:TextBox runat="server" ID="txtShrinkagePct" Text='<%# DataBinder.Eval(Container.DataItem,"shrinkagePct") %>' |
| AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="shrinkageQty" DataType="System.Int64" HeaderText="Shrk Qty" |
| SortExpression="shrinkageQty" UniqueName="shrinkageQty" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridTemplateColumn DataField="ssAsInd" DataType="System.Int64" |
| HeaderText="SS/AS" SortExpression="ssAsInd" UniqueName="ssAsInd"> |
| <ItemTemplate> |
| <asp:TextBox runat="server" ID="txtSsAsInd" Text='<%# DataBinder.Eval(Container.DataItem,"ssAsInd") %>' |
| AutoPostBack="true" OnTextChanged="CmlGridFieldsTextChanged" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="expDate" DataType="System.String" HeaderText="Exp Date" |
| SortExpression="expDate" UniqueName="expDate" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="suplExpDate" DataType="System.String" HeaderText="Sup Exp Date" |
| SortExpression="suplExpDate" UniqueName="suplExpDate" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="qteOrdType" DataType="System.String" HeaderText="Quote /Order Type" |
| SortExpression="qteOrdType" UniqueName="qteOrdType" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="priceRecQty" DataType="System.Int64" HeaderText="Price Rec Qty" |
| SortExpression="priceRecQty" UniqueName="priceRecQty" DataFormatString="<nobr>{0}</nobr>" /> |
| <telerik:GridBoundColumn DataField="frzInd" DataType="System.Int64" HeaderText="FRZ" |
| SortExpression="frzInd" UniqueName="frzInd" DataFormatString="<nobr>{0}</nobr>" /> |
| </Columns> |
| <NoRecordsTemplate> |
| <div> |
| There are no records to display.</div> |
| </NoRecordsTemplate> |
| </MasterTableView> |
| <GroupingSettings CaseSensitive="false" /> |
| <ClientSettings AllowRowsDragDrop="false" AllowKeyboardNavigation="true"> |
| <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> |
| <Scrolling AllowScroll="true" UseStaticHeaders="true" FrozenColumnsCount="1" SaveScrollPosition="true" /> |
| <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </div> |
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Web; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using Harris.Common.ModelStateWrapper_ASPNET; |
| using Harris.Project.Mammoth.Domain; |
| using Harris.Project.Mammoth.ServiceManager; |
| using Telerik.Web.UI; |
| public partial class UserControls_CmlDetailsGrid : System.Web.UI.UserControl |
| { |
| Common _common; |
| private CmlDetailsService _cmldSvc; |
| ModelStateWrapper _modelStateWrapper; |
| /// <summary> |
| /// Handles Page_Load event of CMLDetailsGrid control. |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| } |
| /// <summary> |
| /// Fills the CML Details grid from the database.. |
| /// </summary> |
| /// <param name="cmlId">cmlId of type long</param> |
| public void FilterCmlDetailsData(long cmlId) |
| { |
| if (_common == null) _common = new Common(Session, Request); |
| if (_modelStateWrapper == null) _modelStateWrapper = new ModelStateWrapper(_common.GetDictionary()); |
| if (_cmldSvc == null) _cmldSvc = new CmlDetailsService(_modelStateWrapper); |
| RadGrid_CMLDetails.DataSource = _cmldSvc.GetCmlDetailsByCmlId(cmlId); |
| RadGrid_CMLDetails.Rebind(); |
| CmlDetails_SetToolTip(); |
| } |
| #region Tooltip creation for textboxes to enable excel like grid. |
| /// <summary> |
| /// Prerender call to add javascript which allows tabbing through textboxes in grid. |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| protected void RadGrid_CMLDetails_PreRender(object sender, EventArgs e) |
| { |
| CmlDetails_SetToolTip(); |
| } |
| /// <summary> |
| /// Returns a string used to dynamically assign the javascript for excel like movement in grid. |
| /// </summary> |
| /// <param name="self">textbox making the call.</param> |
| /// <param name="leftBox">textbox to the left of caller, "noControl" if none.</param> |
| /// <param name="rightBox">textbox to the right of caller, "noControl" if none.</param> |
| /// <param name="dataItem">current dataitem from grid.</param> |
| /// <param name="location">either top or bottom, used to determine if this is the first or last item ingrid.</param> |
| /// <returns>strSelf + "','" + strUp + "','" + strDown + "','" + strLeft + "','" + strRight;</returns> |
| private string GetTexboxAttributes(string self, string leftBox, string rightBox, GridDataItem dataItem, string location) |
| { |
| // Cast self as textbox since it will always have something in it. |
| TextBox txtSelf = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex].FindControl(self) as TextBox; |
| string strSelf = txtSelf.ClientID; |
| // Get what should be above. |
| string strUp = string.Empty; |
| if (location != "top") |
| { |
| TextBox txtUp = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex - 1].FindControl(self) as TextBox; |
| strUp = txtUp.ClientID; |
| } |
| else |
| { |
| strUp = "noControl"; |
| } |
| // Get what should be below. |
| string strDown = string.Empty; |
| if (location != "bottom") |
| { |
| TextBox txtDown = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex + 1].FindControl(self) as TextBox; |
| strDown = txtDown.ClientID; |
| } |
| else |
| { |
| strDown = "noControl"; |
| } |
| // Need a string for the left box in grid. |
| string strLeft = string.Empty; |
| if (leftBox == "noControl") |
| { |
| strLeft = "noControl"; |
| } |
| else |
| { |
| TextBox txtLeft = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex].FindControl(leftBox) as TextBox; |
| strLeft = txtLeft.ClientID; |
| } |
| // Need a string for the right box in grid. |
| string strRight = string.Empty; |
| if (rightBox == "noControl") |
| { |
| strRight = "noControl"; |
| } |
| else |
| { |
| TextBox txtRight = RadGrid_CMLDetails.MasterTableView.Items[dataItem.ItemIndex].FindControl(rightBox) as TextBox; |
| strRight = txtRight.ClientID; |
| } |
| string strAttributes = strSelf + "','" + strUp + "','" + strDown + "','" + strLeft + "','" + strRight; |
| return strAttributes; |
| } |
| /// <summary> |
| /// Called by preRender to set tool tips on each textbox in grid. |
| /// </summary> |
| private void CmlDetails_SetToolTip() |
| { |
| int itemsInGrid = RadGrid_CMLDetails.Items.Count; |
| foreach (GridDataItem dataItem in RadGrid_CMLDetails.Items) |
| { |
| var txtArQty = (dataItem.FindControl("txtArQty") as TextBox); |
| var txtMinBuyQty = (dataItem.FindControl("txtMinBuyQty") as TextBox); |
| var txtShrinkagePct = (dataItem.FindControl("txtShrinkagePct") as TextBox); |
| var txtSsAsInd = (dataItem.FindControl("txtSsAsInd") as TextBox); |
| // |
| var rowToolTip = string.Empty; |
| // Need to get the StructureID from the hidden gridfield |
| // so I attached it to the tooltip part of the textbox. |
| for (int ix = 0; ix < dataItem.Cells.Count; ix++) |
| { |
| if (dataItem.Cells[ix].Text != " ") |
| { |
| rowToolTip = dataItem.Cells[ix].Text; |
| break; |
| } |
| } |
| // Set tooltips for all four textboxes. |
| txtArQty.ToolTip = rowToolTip; |
| txtMinBuyQty.ToolTip = rowToolTip; |
| txtShrinkagePct.ToolTip = rowToolTip; |
| txtSsAsInd.ToolTip = rowToolTip; |
| // string self, string leftBox, string rightBox, GridDataItem dataItem, string location |
| // Top row in grid. |
| if (dataItem.ItemIndex == 0) |
| { |
| // Get locations for first box left to right. |
| string strArQtyAttributes = GetTexboxAttributes(txtArQty.ID, "noControl", txtMinBuyQty.ID, dataItem, "top"); |
| txtArQty.Attributes.Add("onkeydown", "setFocus('" + strArQtyAttributes + "');"); |
| // Get locations for second box left to right. |
| string strMinBuyQtyAttributes = GetTexboxAttributes(txtMinBuyQty.ID, txtArQty.ID, txtShrinkagePct.ID, dataItem, "top"); |
| txtMinBuyQty.Attributes.Add("onkeydown", "setFocus('" + strMinBuyQtyAttributes + "');"); |
| // Get locations for third box left to right. |
| string strShrinkagePctAttributes = GetTexboxAttributes(txtShrinkagePct.ID, txtMinBuyQty.ID, txtSsAsInd.ID, dataItem, "top"); |
| txtShrinkagePct.Attributes.Add("onkeydown", "setFocus('" + strShrinkagePctAttributes + "');"); |
| // Get locations for third box left to right. |
| string strSsAsIndAttributes = GetTexboxAttributes(txtSsAsInd.ID, txtShrinkagePct.ID, "noControl", dataItem, "top"); |
| txtSsAsInd.Attributes.Add("onkeydown", "setFocus('" + strSsAsIndAttributes + "');"); |
| } |
| // Used to handle middle rows in grid. |
| else if (dataItem.ItemIndex > 0 && dataItem.ItemIndex < RadGrid_CMLDetails.MasterTableView.Items.Count - 1) |
| { |
| // Get locations for first box left to right. |
| string strArQtyAttributes = GetTexboxAttributes(txtArQty.ID, "noControl", txtMinBuyQty.ID, dataItem, "mid"); |
| txtArQty.Attributes.Add("onkeydown", "setFocus('" + strArQtyAttributes + "');"); |
| // Get locations for second box left to right. |
| string strMinBuyQtyAttributes = GetTexboxAttributes(txtMinBuyQty.ID, txtArQty.ID, txtShrinkagePct.ID, dataItem, "mid"); |
| txtMinBuyQty.Attributes.Add("onkeydown", "setFocus('" + strMinBuyQtyAttributes + "');"); |
| // Get locations for third box left to right. |
| string strShrinkagePctAttributes = GetTexboxAttributes(txtShrinkagePct.ID, txtMinBuyQty.ID, txtSsAsInd.ID, dataItem, "mid"); |
| txtShrinkagePct.Attributes.Add("onkeydown", "setFocus('" + strShrinkagePctAttributes + "');"); |
| // Get locations for third box left to right. |
| string strSsAsIndAttributes = GetTexboxAttributes(txtSsAsInd.ID, txtShrinkagePct.ID, "noControl", dataItem, "mid"); |
| txtSsAsInd.Attributes.Add("onkeydown", "setFocus('" + strSsAsIndAttributes + "');"); |
| } |
| else if (dataItem.ItemIndex == RadGrid_CMLDetails.MasterTableView.Items.Count - 1) |
| { |
| // Get locations for first box left to right. |
| string strArQtyAttributes = GetTexboxAttributes(txtArQty.ID, "noControl", txtMinBuyQty.ID, dataItem, "bottom"); |
| txtArQty.Attributes.Add("onkeydown", "setFocus('" + strArQtyAttributes + "');"); |
| // Get locations for second box left to right. |
| string strMinBuyQtyAttributes = GetTexboxAttributes(txtMinBuyQty.ID, txtArQty.ID, txtShrinkagePct.ID, dataItem, "bottom"); |
| txtMinBuyQty.Attributes.Add("onkeydown", "setFocus('" + strMinBuyQtyAttributes + "');"); |
| // Get locations for third box left to right. |
| string strShrinkagePctAttributes = GetTexboxAttributes(txtShrinkagePct.ID, txtMinBuyQty.ID, txtSsAsInd.ID, dataItem, "bottom"); |
| txtShrinkagePct.Attributes.Add("onkeydown", "setFocus('" + strShrinkagePctAttributes + "');"); |
| // Get locations for third box left to right. |
| string strSsAsIndAttributes = GetTexboxAttributes(txtSsAsInd.ID, txtShrinkagePct.ID, "noControl", dataItem, "bottom"); |
| txtSsAsInd.Attributes.Add("onkeydown", "setFocus('" + strSsAsIndAttributes + "');"); |
| } |
| } |
| } |
| #endregion |
| /// <summary> |
| /// Handles textchange event updates the quantity of the structure, and updates the tree. |
| /// This is used by both the WhereUsed grid and the ChildGrid. |
| /// </summary> |
| /// <param name="sender"></param> |
| /// <param name="e"></param> |
| protected void CmlGridFieldsTextChanged(object sender, EventArgs e) |
| { |
| TextBox txtChangeQuantity = ((TextBox)sender); |
| Int32 newQuantity = Int32.Parse(txtChangeQuantity.Text); |
| long structureId = long.Parse(txtChangeQuantity.ToolTip); |
| // get the structure record from the database |
| //var structureToUpdate = _structSvc.GetStructure(structureId); |
| //if (structureToUpdate != null) |
| //{ |
| // structureToUpdate.Qty = newQuantity; |
| // var modStructure = _structSvc.EditStructure(structureToUpdate, _userName); |
| // if (modStructure != null) |
| // { |
| // // Update tree with new quantity. |
| // RadTreeView myStructureView = (RadTreeView)Parent.FindControl("StructureView"); |
| // _cgtree.ProcessTreeInstructions(_structSvc.TreeInstructions, myStructureView); |
| // } |
| // else |
| // { |
| // _modelStateWrapper.AddError("Structure Error", "Error updating structure data {" + structureId + "}"); |
| // } |
| //} |
| } |
| } |
| <telerik:RadAjaxManagerProxy ID="RadAjaxManager_DetailsGrid" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadGrid_CMLDetails"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadGrid_CMLDetails" /> |
| <telerik:AjaxUpdatedControl ControlID="txtArQty" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="txtArQty"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="txtArQty" /> |
| <telerik:AjaxUpdatedControl ControlID="RadGrid_CMLDetails" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManagerProxy> |
Good day!
I'm trying to delete records from a grid via javascript (__doPostBack() method). For the __doPostBack(), I'm passing in the client ID of a RadMenu. I'm able to successfully delete records from the grid, and it refreshes ok. But if I add the RadMenu to my
AjaxSetting and the Grid as the AjaxUpdatedControl, the grid doesn't refresh anymore eventhough the loading panel appears.
Why is this so?
Thank you very much.
| <telerik:RadGrid ID="RadGrid1" runat="server" PageSize="10" Skin="Default" GridLines="None" |
| AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True" AllowMultiRowEdit="true" |
| ShowGroupPanel="True" GroupingEnabled="False" EnableLinqExpressions="false" |
| BorderWidth="1px" BorderColor="Gainsboro" |
| OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource" |
| OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound" |
| OnInsertCommand="RagGrid1_InsertCommand" |
| > |
| <PagerStyle Mode="NextPrevNumericAndAdvanced" CssClass="tbl"></PagerStyle> |
| <ClientSettings ReorderColumnsOnClient="false" AllowDragToGroup="true" AllowColumnsReorder="false"> |
| <Selecting AllowRowSelect="True"></Selecting> |
| <ClientEvents OnRowDblClick="RowDblClick" /> |
| <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="False" |
| ScrollHeight="250" /> |
| </ClientSettings> |
| <MasterTableView DataKeyNames="FileChecklistReferenceId" EditMode="InPlace" TableLayout="Fixed" AllowFilteringByColumn="true" AutoGenerateColumns="false" CommandItemDisplay="Top"> |
| <EditItemStyle Font-Bold="true"/> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="Checklist" HeaderText="Checklist"> |
| <ItemTemplate> |
| <%#Eval("FileType")%> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <asp:DropDownList ID="ddlFileType" runat="server" CssClass="ddl" /> |
| <asp:RequiredFieldValidator ID="rfvFileType" runat="server" ControlToValidate="ddlFileType" Text="*" ErrorMessage="Please Select a Checklist" SetFocusOnError="True" InitialValue="-1" ValidationGroup="SaveGroup" /> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Reference" HeaderText="Reference" ItemStyle-Font-Bold="true" /> |
| <telerik:GridNumericColumn UniqueName="Threshold" ConvertEmptyStringToNull="true" DataType="System.Double" HeaderText="Threshold" NumericType="Currency" DataField="Threshold" /> |
| <%--<telerik:GridEditCommandColumn HeaderStyle-Width="80px" />--%> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) |
| { |
| if (e.CommandName == RadGrid.InitInsertCommandName) |
| { |
| //Get the filechecklist from Viewstate |
| List<FileChecklist> fileList = (List<FileChecklist>)ViewState["Checklists"]; |
| //Add a new file checklist object to it |
| fileList.Add(new FileChecklist()); |
| //Save it back to ViewState |
| ViewState["Checklists"] = fileList; |
| e.Canceled = true; |
| System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); |
| //the values set here must match the values types declared in the class (Model) otherwise, an exception will be thrown |
| //if any of the values do not "match" you will get a "Specified cast is not valid." exception |
| newValues["FileTypeId"] = -1; |
| newValues["FileChecklistReferenceId"] = -1; |
| newValues["Threshold"] = 0.0; |
| //Insert the item and rebind |
| e.Item.OwnerTableView.InsertItem(newValues); |
| } |
| } |
| protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) |
| { |
| RadGrid rg = (RadGrid)sender; |
| List<FileChecklist> fileList = (List<FileChecklist>)ViewState["Checklists"]; |
| rg.DataSource = fileList; |
| } |
| private void SaveFileChecklists(ref Question data) |
| { |
| List<FileChecklist> newList = new List<FileChecklist>(); |
| foreach (GridDataItem row in RadGrid1.MasterTableView.Items) |
| { |
| int id = Convert.ToInt32(row.OwnerTableView.DataKeyValues[row.ItemIndex]["FileChecklistReferenceId"]); |
| FileChecklist fc = new FileChecklist(); |
| DropDownList ddl = (row.FindControl("ddlFileType") as DropDownList); //null |
| TextBox tb = (row["Reference"].Controls[0] as TextBox); //throws index out of range error |
| RadNumericTextBox rtb = (row["Threshold"].Controls[0] as RadNumericTextBox);//throws index out of range error |
| } |
| data.FileChecklists = newList; |
| } |

| <telerik:GridBoundColumn DataField="Date" HeaderText="Date" UniqueName="Date" DataFormatString="{0:MM/dd/yyyy hh:mm:ss}" > |