I can't seem to get to the grid in a function
the function throws a null object error
the function throws a null object error
<telerik:RadGrid ID="rgEditOrder" OnNeedDataSource="rgEditOrder_NeedDataSource" OnItemCommand="rgEditOrder_ItemCommand" OnItemUpdated="rgEditOrder_UpdateRow" OnItemCreated="rgEditOrder_OnItemCreated" runat="server"> <GroupingSettings CaseSensitive="false" /> <MasterTableView DataKeyNames="OrderSeq" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true" AllowFilteringByColumn="False" EditMode="InPlace" > <Columns> <telerik:GridBoundColumn UniqueName="StoreNumber" DataField="StoreNumber" HeaderText="Store #" DataFormatString="{0:#####}" DataType="System.Int32" ReadOnly="True"> <HeaderStyle Width="40px" /> </telerik:GridBoundColumn>a bunch of columns <telerik:GridTemplateColumn UniqueName="Qty" HeaderText="Cases" > <ItemTemplate> <asp:Label ID="lblQty" Text='<%# Bind("Qty") %>' Width="40px" runat="server" /> </ItemTemplate> <EditItemTemplate> <telerik:RadNumericTextBox ID="rntbQty" Text='<%# Eval("Qty") %>' MinValue='<%# Bind("Qty") %>' Width="40px" runat="server"> <NumberFormat DecimalDigits="0" /> </telerik:RadNumericTextBox> </EditItemTemplate> <HeaderStyle Width="40px" /> </telerik:GridTemplateColumn>more columns <telerik:GridBoundColumn UniqueName="OrderSeq" DataField="OrderSeq" DataType="System.Int64" Visible="false"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings EnablePostBackOnRowClick="true" > <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> </telerik:RadGrid><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"><title>Edit Order</title><script language="javascript" type="text/javascript"><!--// this function handles the onbeforeprint event of the body objectfunction window_onbeforeprint(){ // idprint is the id assigned to the div tag of the javascript // injected into the response object in the code behind which // actually prints the screen var divEle = document.getElementById("idPrint"); // remove the display=none i.e. show the div element if (divEle != null) { divEle.style.display = ""; } // hide the div elements idShow.style.display="none"; // idShow.style.display="none"; // idShow1.style.display="none"; idShow1.style.display="none"; idHeader.style.display="none"; }// this function handles the onafterprint event of the body objectfunction window_onafterprint(){ // idprint is the id assigned to the div tag of the javascript // injected into the response object in the code behind which // actually prints the screen var divEle = document.getElementById("idPrint"); // hide the div element if (divEle != null) { divEle.style.display = "none"; } // remove the style.display='none'-show the div element idShow.style.display=""; // idShow1.style.display=""; idShow1.style.display=""; idHeader.style.display="";}var idx = 0;function RowDblClick(sender, eventArgs) { idx = eventArgs.get_itemIndexHierarchical(); sender.get_masterTableView().editItem(idx);}// this function is called on the click event of the Finalize Order button// it is wired to the button in the page load event function check_input() { // both the first and last name need to be entered-if either of them is not // popup message box and cancel update var strName = document.getElementById('txtFirstName'); if (trim(strName.value) == "") { alert("Please Enter First Name"); return (false); } strName = document.getElementById('txtLastName'); if (trim(strName.value) == "") { alert("Please Enter Last Name"); return (false); } return (true);}// use regular expression to format first or last name// per Derek-remove any imbedded white spacefunction trim(str) { return str.replace(/^\s+|\s+$/g, '');}// this functiom was added because the code behind is looking for it function PrintPage() { return true;}--></script></head>protected void rgEditOrder_OnItemCreated(object source, GridItemEventArgs e){ StringBuilder sb; GridEditableItem geItem; TableCell tcQty; RadNumericTextBox rntbQty; char DoubleQuote; string EscapeChar,str; DoubleQuote = (char) 34; sb = new StringBuilder(DoubleQuote); EscapeChar = sb.ToString(); str = DoubleQuote.ToString(); if (e.Item.IsInEditMode) { } else return; if (e.Item is GridEditableItem) { } else return; geItem = (GridEditableItem)(e.Item); sb = new StringBuilder("<script language="); sb.Append(@"'"); sb.Append("javascript"); sb.Append(@"'"); sb.Append(" "); sb.Append(@"'"); sb.Append("text/javascript"); sb.Append(@"'"); sb.Append(">"); sb.Append("function QtyOnValueChanged(sender, eventArgs) { "); sb.Append("alert("); sb.Append(@"'"); sb.Append("gorkomatic"); sb.Append(@"'"); sb.Append("); "); sb.Append("var grid = $find("); sb.Append(@"'"); sb.Append("<%= "); sb.Append("rgEditOrder.ClientID"); sb.Append(" %>"); sb.Append(@"'"); sb.Append(").get_masterTableView(); "); sb.Append("grid.updateItem(grid.get_dataItems()["); sb.Append(geItem.DataSetIndex.ToString()); sb.Append("].get_element()); "); sb.Append("alert("); sb.Append(@"'"); sb.Append("qty on value changed"); sb.Append(@"'"); sb.Append("); }"); sb.Append("</script>"); str = sb.ToString(); rcBlock.Controls.Add(new LiteralControl(str)); // ScriptManager.RegisterStartupScript(this,this.GetType(), "Update", str, false); tcQty = geItem.Cells[1]; rntbQty = (RadNumericTextBox)tcQty.FindControl("rntbQty"); if (rntbQty == null) return; rntbQty.ClientEvents.OnValueChanged = "QtyOnValueChanged";}