Hi
I have been searching for hours, but haven't managed to find any relevant help.
I'm coding based on the following example "Grid - User Control Edit Form". My only issue is that my code is slightly more complicated as I'd like to make use of functional code on the user control.
In my example I have a RadGrid with a list of users. I want to be able to insert users from this user control edit form.
There is a RadGrid on the edit form that will need to be populated based on user entry into certain text boxes. The user will click on a search button and the RadGrid will be populated with the relevant results. The user will then select the relevant record from the grid to populate some other textboxes on the same form.
My issue is that I can't get this grid to update. I've tested with simple label and it won't update either. The event does fire, I can step through it while debugging, but the update is not done.
My only assumption is that this is due to an ajax issue or setting that I'm missing.
My code is as follows (I am only going to post the relevant code).
aspx:
The user control ascx:
ascx.cs
In the above code the problem is in the ascx.cs file in the "
I've tried numerous options with the ajax settings - these include setting it up like above, using the ajaxproxy, adding an ajax manager to the actual user control. I've taken the AutoPostBack off and put it on.
Nothing is working.
Any help would be greatly appreciated.
I have been searching for hours, but haven't managed to find any relevant help.
I'm coding based on the following example "Grid - User Control Edit Form". My only issue is that my code is slightly more complicated as I'd like to make use of functional code on the user control.
In my example I have a RadGrid with a list of users. I want to be able to insert users from this user control edit form.
There is a RadGrid on the edit form that will need to be populated based on user entry into certain text boxes. The user will click on a search button and the RadGrid will be populated with the relevant results. The user will then select the relevant record from the grid to populate some other textboxes on the same form.
My issue is that I can't get this grid to update. I've tested with simple label and it won't update either. The event does fire, I can step through it while debugging, but the update is not done.
My only assumption is that this is due to an ajax issue or setting that I'm missing.
My code is as follows (I am only going to post the relevant code).
aspx:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePartialRendering="true"></telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManagerManager" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="CustomerGrid"> <UpdatedControls><telerik:AjaxUpdatedControl ControlID="CustomerGrid" LoadingPanelID="RadAjaxLoadingPanel1" /></UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" Transparency="30" Skin="WebBlue"></telerik:RadAjaxLoadingPanel> <telerik:RadGrid ID="CustomerGrid" runat="server" Skin="WebBlue" PageSize="10" Width="100%" AllowPaging="true" AutoGenerateColumns="False" HorizontalAlign="Center" ShowStatusBar="True" OnItemCreated="RadGrid1_ItemCreated" AllowAutomaticInserts="true" CellSpacing="0" GridLines="None" AllowSorting="True" AllowFilteringByColumn="true" EnableLinqExpressions="false"> <PagerStyle Mode="NextPrevAndNumeric" /> <GroupingSettings CaseSensitive="false" /> <FilterMenu EnableImageSprites="False"></FilterMenu> <ClientSettings> <Selecting AllowRowSelect="true"/> <ClientEvents OnRowSelected="RowSelected" /> </ClientSettings> <MasterTableView CanRetrieveAllData="true" CommandItemDisplay="Top" DataKeyNames="CustomerId,CustomerName,CustomerFullAddress" EditMode="PopUp"> <CommandItemSettings AddNewRecordText="Add New Customer" /> <EditFormSettings UserControlName="helpers/Customer_Form.ascx" EditFormType="WebUserControl" InsertCaption="Add New Customer" CaptionFormatString="Edit CustomerId: {0}" CaptionDataField="CustomerId"> <PopUpSettings Modal="True" Width="750px"></PopUpSettings> </EditFormSettings> <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn> <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="CustomerId" Display="false" HeaderText="NV" SortExpression="customerId" Visible="true" UniqueName="CompanyIdd"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CustomerLat" Display="false" HeaderText="NV" SortExpression="customerId" Visible="true" UniqueName="cusLatt"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CustomerLon" Display="false" HeaderText="NV" SortExpression="customerId" Visible="true" UniqueName="cusLonn"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CustomerName" HeaderText="Name" SortExpression="customerName" UniqueName="customerNamee" ShowFilterIcon="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CustomerFullAddress" HeaderText="Address" SortExpression="adress" UniqueName="adresss" ShowFilterIcon="false" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"></telerik:GridBoundColumn> <telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="50px" HeaderStyle-HorizontalAlign="center" ItemStyle-HorizontalAlign="center" HeaderText="History" UniqueName="vhistory"> <ItemTemplate> <asp:LinkButton runat="server" ID="rbtnViewhistory" CommandName="ViewHistory" CommandArgument='<%# Eval("CustomerId") %>' ><asp:Image ID="deleteButton" runat="server" ImageUrl="images/icons/general/icon_general_view.png" AlternateText="Delete" /></asp:LinkButton> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView>The user control ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Customer_Form.ascx.cs" Inherits="helpers_Customer_Form" %><%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> <table width="100%" cellpadding="5px"> <tr> <td style="width:110px;"><asp:Label ID="lblCustomerName" runat="server" Text=" Customer Name"></asp:Label></td> <td><telerik:RadTextBox ID="tbCustomerName" runat="server" Text=""></telerik:RadTextBox></td> </tr> <tr> <td><asp:Label ID="lblFirstname" runat="server" Text=" Firstname"></asp:Label></td> <td><telerik:RadTextBox ID="tbFirstname" runat="server" Text=""></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblLastname" runat="server" Text=" Surname"></asp:Label></td> <td><telerik:RadTextBox ID="tbLastname" runat="server" Text=""></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblAddress1" runat="server" Text=" Address1"></asp:Label></td> <td><telerik:RadTextBox ID="tbAddress1" runat="server"></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblAddress2" runat="server" Text=" Address2"></asp:Label></td> <td><telerik:RadTextBox ID="tbAddress2" runat="server" Text="" ></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblAddress3" runat="server" Text=" Address3"></asp:Label></td> <td><telerik:RadTextBox ID="tbAddress3" runat="server" Text=""></telerik:RadTextBox></td> </tr><tr> <td valign="top"><asp:Label ID="lblPostalCode" runat="server" Text=" Postal Code"></asp:Label></td> <td><telerik:RadTextBox ID="tbPostalCode" runat="server" Text="" MaxLength="4" Width="40px" ></telerik:RadTextBox> <telerik:RadButton ID="btnG1" runat="server" onclick="btnG1_Click" Text="Get Results" Width="110px" AutoPostBack="true" /> <br /> <telerik:RadGrid ID="GridGeoResults" runat="server" Skin="WebBlue" PageSize="20" AllowPaging="True" AutoGenerateColumns="False" ShowStatusBar="True" CellSpacing="0" GridLines="None" AllowSorting="True" AllowFilteringByColumn="False" OnItemDataBound="GridGeoResults_ItemDataBound" AllowMultiRowSelection="false" > <PagerStyle Mode="NextPrevAndNumeric" /> <ClientSettings><Selecting AllowRowSelect="true" /></ClientSettings> <MasterTableView AllowAutomaticInserts="false" AutoGenerateColumns="False" Width="100%"> <Columns> <telerik:GridTemplateColumn HeaderText="" HeaderStyle-Width="20px" > <ItemTemplate> <asp:RadioButton ID="selectRadioButton" runat="server" OnCheckedChanged="selectRadioButton_CheckedChanged" AutoPostBack="true" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="Address" ItemStyle-Wrap="false" HeaderText="Address" SortExpression="Address" UniqueName="Address"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Result1" ItemStyle-Wrap="false" HeaderText="Result1" SortExpression="Result1" UniqueName="Result1"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Result2" ItemStyle-Wrap="false" HeaderText="Result2" SortExpression="Result2" UniqueName="Result2"></telerik:GridBoundColumn> <telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="50px" HeaderStyle-HorizontalAlign="center" ItemStyle-HorizontalAlign="center" HeaderText=""> <ItemTemplate> <asp:LinkButton runat="server" ID="viewMapLinkButton"><asp:Image ID="viewButton" runat="server" ImageUrl="../images/icons/mapping/numbers/green.png" Width="15px" Height="15px" AlternateText="View on Map" ToolTip="View on Map" /></asp:LinkButton> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> </telerik:RadGrid> </td> </tr><tr> <td><asp:Label ID="lblResult1" runat="server" Text=" Result1"></asp:Label></td> <td><telerik:RadTextBox ID="tbResult1" runat="server"></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblResult1" runat="server" Text=" Result2"></asp:Label></td> <td><telerik:RadTextBox ID="tbResult2" runat="server"></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblTel1" runat="server" Text=" Tel1"></asp:Label></td> <td><telerik:RadTextBox ID="tbTel1" runat="server" Text=""></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblTel2" runat="server" Text=" Tel2"></asp:Label></td> <td><telerik:RadTextBox ID="tbTel2" runat="server" Text=""></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblFax1" runat="server" Text=" Fax1"></asp:Label></td> <td><telerik:RadTextBox ID="tbFax1" runat="server"></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblFax2" runat="server" Text=" Fax2"></asp:Label></td><td> <telerik:RadTextBox ID="tbFax2" runat="server"></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblEmail1" runat="server" Text=" Email1"></asp:Label></td> <td><telerik:RadTextBox ID="tbEmail1" runat="server"></telerik:RadTextBox></td> </tr><tr> <td><asp:Label ID="lblEmail2" runat="server" Text=" Email2"></asp:Label></td> <td><telerik:RadTextBox ID="tbEmail2" runat="server"></telerik:RadTextBox></td> </tr><tr> <td colspan="2"> <telerik:RadButton ID="rbtnInsertCustomer" runat="server" Text="Add" CommandName="InsertCustomer" Width="110px"></telerik:RadButton> <telerik:RadButton ID="rbtnCancelCustomerInsert" runat="server" Text="Cancel" CommandName="CancelCustomerInsert" Width="110px"></telerik:RadButton> <br /><asp:Label ID="lblError1" runat="server" Visible="false" CssClass="errorLabel" /> </td> </tr> </table>ascx.cs
public partial class helpers_Customer_Form : System.Web.UI.UserControl{ User loggedInUser; private object _dataItem = null; protected void Page_Load(object sender, EventArgs e) { RadAjaxManager manager = RadAjaxManager.GetCurrent(Page); manager.AjaxSettings.AddAjaxSetting(btnGeocode1, btnGeocode1); manager.AjaxSettings.AddAjaxSetting(btnGeocode1, GridGeoResults); manager.AjaxSettings.AddAjaxSetting(btnGeocode1, lblError1); loggedInUser = (User)HttpContext.Current.Session["loggedInUser"]; } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { // this.DataBinding += new System.EventHandler(this.helpers_Customer_Form_DataBinding); } #endregion public object DataItem { get { return this._dataItem; } set { this._dataItem = value; } } protected void btnG1_Click(object sender, EventArgs e) { /* THIS CODE IS EXECUTING WITH NO ISSUES - BUT UPDATES AREN'T BEING SHOWN */ this.lblError1.Text = "Test"; this.lblError1.Visible = true; this.GridGResults.DataSource = GetMyInfoHere(null, tbAddress1.Text); this.GridGResults.DataBind(); } protected void GridGResults_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { DataRowView drv = (DataRowView)e.Item.DataItem; // add functionality here } } protected void selectRadioButton_CheckedChanged(object sender, EventArgs e) { GridDataItem gridItem = (sender as RadioButton).Parent.Parent as GridDataItem; this.tbResult1.Text = gridItem.Cells[4].Text; this.tbResult2.Text = gridItem.Cells[5].Text; this.GridGResults.Visible = false; }}In the above code the problem is in the ascx.cs file in the "
protected void btnGeocode1_Click(object sender, EventArgs e)" function. It is being called and I can step through it while debugging, but the label is not shown and the grid's data is not updated. I've tried numerous options with the ajax settings - these include setting it up like above, using the ajaxproxy, adding an ajax manager to the actual user control. I've taken the AutoPostBack off and put it on.
Nothing is working.
Any help would be greatly appreciated.