This is a migrated thread and some comments may be shown as answers.

Grid getting disappeared on updating any of the rows information

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saurabh
Top achievements
Rank 1
Saurabh asked on 29 Nov 2011, 01:49 PM
Hello,
I'm using the telerik grid but when I try to update any of the information, the grid disappears completely. Following are the steps I follow:
1. Click on the 'Edit' button for any of the row and update any information.
2. Press Update button.

As soon as I press 'Update' button, grid disappears. And when I reload the page, it appears again.
Following is the html code:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
  <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="tgLicenseInfo">
      <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="tgLicenseInfo" LoadingPanelID="RadAjaxLoadingPanel1" />
      </UpdatedControls>
    </telerik:AjaxSetting>
  </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
<telerik:RadGrid ID="tgLicenseInfo" runat="server" AutoGenerateColumns="false" AllowSorting="true"
                                                            AllowPaging="true" AllowFilteringByColumn="true" OnNeedDataSource="tgLicenseInfo_NeedDataSource"
                                                            OnUpdateCommand="tgLicense_UpdateCommand">
  <EditItemStyle BackColor="AliceBlue" />
  <PagerStyle Mode="NextPrevAndNumeric" />
  <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" CommandItemDisplay="TopAndBottom" EditFormSettings-PopUpSettings-Modal="true">
    <Columns>
    <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-HorizontalAlign="Center"
                                                                        UniqueName="EditCommandColumn" HeaderText="Edit" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridBoundColumn DataField="ID" UniqueName="ID" Visible="false" />
    <telerik:GridBoundColumn DataField="LNumber" HeaderText="License #" SortExpression="LNumber"
                                                                        UniqueName="LNumber" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridBoundColumn DataField="StateDesc" HeaderText="State" SortExpression="StateDesc"
                                                                        UniqueName="StateDesc" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridBoundColumn DataField="LType" HeaderText="Type" SortExpression="LType"
                                                                        UniqueName="LType" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridBoundColumn DataField="LHolder" HeaderText="Holder" SortExpression="LHolder"
                                                                        UniqueName="LHolder" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridBoundColumn DataField="LExpireDate" HeaderText="ExpireDate" SortExpression="LExpireDate"
                                                                        UniqueName="LExpireDate" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridBoundColumn DataField="LicenseStatus" HeaderText="Status" SortExpression="LicenseStatus"
                                                                        UniqueName="LicenseStatus" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridBoundColumn DataField="VerifiedByUserID" HeaderText="Verified By" SortExpression="VerifiedByUserID"
                                                                        UniqueName="VerifiedByUserID" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    <telerik:GridButtonColumn Text="Delete" CommandName="Delete" HeaderText="Delete"
                                                                        ButtonType="ImageButton" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
    </Columns>
    <EditFormSettings EditFormType="Template">
      <EditColumn UniqueName="EditColumn"> </EditColumn>
      <FormTemplate>
        <table border="0" cellpadding="2">
          <tr>
            <td> License #:  </td>
            <td><asp:TextBox ID="txtLNumber" Width="150px" Text='<%# Bind( "LNumber") %>' runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td> State:  </td>
            <td><asp:TextBox ID="txtState" Width="150px" Text='<%# Bind( "StateDesc") %>' runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td> Type:  </td>
            <td><asp:TextBox ID="txtLType" Width="150px" Text='<%# Bind( "LType") %>' runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td> Holder:  </td>
            <td><asp:TextBox ID="txtLHolder" Width="150px" Text='<%# Bind( "LHolder") %>' runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td> Exp Date:  </td>
            <td><asp:TextBox ID="txtLExpireDate" Width="150px" Text='<%# Bind( "LExpireDate") %>'
                                                                                        runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td> Status:  </td>
            <td><asp:TextBox ID="txtStatus" Width="150px" Text='<%# Bind( "LicenseStatus") %>' runat="server"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td> Verified By:  </td>
            <td><asp:TextBox ID="txtVerifiedByUserID" Width="150px" Text='<%# Bind( "VerifiedByUserID") %>'
                                                                                        runat="server"></asp:TextBox>
            </td>
          </tr>
        </table>
        <asp:Button ID="Button3" CommandName="Update" Text="Update" runat="server" />
        <asp:Button ID="Button3a" CommandName="Cancel" Text="Cancel" runat="server" />
      </FormTemplate>
    </EditFormSettings>
  </MasterTableView>
</telerik:RadGrid>


And following is the code behind:
protected void tgLicense_UpdateCommand(object source, GridCommandEventArgs e)
{
 try
  {
   if (e.CommandName == RadGrid.UpdateCommandName)
    {
      if (e.Item is GridEditFormItem)
       {
         GridEditFormItem item = (GridEditFormItem)e.Item;
         int iLID = Convert.ToInt32(item.GetDataKeyValue("ID"));
         if (iLID != 0)
          {
           TextBox txtLHolder = (TextBox)item.FindControl("txtLHolder");
           TextBox txtLType = (TextBox)item.FindControl("txtLType");
           TextBox txtLExpireDate = (TextBox)item.FindControl("txtLExpireDate");
           TextBox txtLicenseStatus = (TextBox)item.FindControl("txtStatus");
           TextBox txtVerifiedByUserID = (TextBox)item.FindControl("txtVerifiedByUserID");
           TextBox txtState = (TextBox)item.FindControl("txtState");
           //    DropDownList drdState = (DropDownList)item.FindControl("drdState");
           SaisUser oUser = (SaisUser)Cache[this.GUID + "User"];
           AgentLicense oLI = oUser.AgentInProcess.LicenseInfo[iLID];
           oLI.LExpireDate = txtLExpireDate.Text;
           oLI.LHolder = txtLHolder.Text;
           oLI.LicenseStatus = Convert.ToBoolean(txtLicenseStatus.Text);
           oLI.VerifiedByUserID = txtVerifiedByUserID.Text;
           oLI.LType = txtLType.Text;
           //      oLI.LState = drdState.SelectedItem.Value;
           oLI.LState = txtState.Text;
           //here license is saved
           ProcessResult oPR = oLI.Save(this.CnxnString, this.LogPath);
           if (oPR.Exception == null)
             {
              oUser.AgentInProcess.LicenseInfo[iLID] = oLI;
              Cache[this.GUID + "User"] = oUser;
              this.tgLicenseInfo.Rebind();
             }
            // else
            //   this.lblUpdate.Text = "Error:" + oPR.Exception.Message;
           }
       }
     }
   }
   catch (Exception Exc)
    {
      string script = "$(function(){initializedialog();showDialog(\"" + Exc.Message + "\");});";
      ScriptManager.RegisterStartupScript(this, this.Page.GetType(), "dialog", script, true);
    }
}

Can some one help me with this issue?

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 01 Dec 2011, 03:18 PM
Hello Saurabh,

Reviewing the code I cannot find anything wrong that could cause the described behavior. The only code line that I find wrong is calling Rebind() for the grid in the UpdateCommand. Try removing it and see if it makes any difference.
Note that Rebind is implicitly called after update as well as after the rest of the commands from this list. And calling Rebind() explicitly might break the control flow.
Also, can you try debugging and confirm that no server-side errors are thrown? I would suggest that you temporary disable ajax until you make sure the grid operations are working properly with regular postbacks. Then you can enable ajax back.

Kind regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Saurabh
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or