Problem with Ajax and RadGrid

2 posts, 0 answers
  1. Carlos
    Carlos avatar
    6 posts
    Member since:
    Oct 2010

    Posted 23 Nov 2010 Link to this post

    Hi, im having some problems, im guessing is my Ajax
    here is my page:

    <asp:Content ID="Content2" ContentPlaceHolderID="cphContenido" runat="server">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="rggrupos">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="rggrupos" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="ImageButton1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="rgotros" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
    <br />
    <telerik:RadGrid ID="rggrupos" DataSourceID="dsGrupos" runat="server"
               AutoGenerateColumns="False" GridLines="none">
                <MasterTableView Width="100%">
                    <GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldAlias="Grupo" FieldName="grupo"></telerik:GridGroupByField>
                                  
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="grupo" SortOrder="Ascending"></telerik:GridGroupByField>
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                    </GroupByExpressions>
                    <Columns>
                        <telerik:GridBoundColumn ColumnEditorID="usuario" UniqueName="usuario" SortExpression="usuario" HeaderText="" HeaderButtonType="TextButton"
                            DataField="usuario">
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn UniqueName="temprespseg"  HeaderText="RESPSEG"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkrespseg" runat="server"/>  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="tempatender"  HeaderText="ATENDER"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkatender" runat="server" />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="tempcomentar"  HeaderText="COMENTAR"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkcomentar" runat="server"  />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="tempenterar"  HeaderText="ENTERAR"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkenterar" runat="server" />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="temparchivar"  HeaderText="ARCHIVAR"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkarchivar" runat="server"  />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                 </Columns>
                </MasterTableView>
      
            </telerik:RadGrid>
      
      
        <asp:SqlDataSource ID="dsGrupos" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MatrizTurnadoConnectionString %>" 
            SelectCommand="SELECT * FROM [usuariosgrupo] Where owner = 'CJ398'">
        </asp:SqlDataSource>
        <br />
        <table>
        <tr>
            <td>
            <asp:Label ID="Label1" runat="server" Text="AGREGAR OTROS CONTACTOS"></asp:Label>
            </td>
            <td>
            <telerik:RadComboBox EmptyMessage="Selecciona Usuario" EnableLoadOnDemand="True" ShowMoreResultsBox="true"
                    EnableVirtualScrolling="true" ID="rcbotros" Runat="server" DataSourceID="dsusuario" 
                    DataTextField="NC" DataValueField="emailLotusInt" Height="100px" 
                    Width="362px">
                    </telerik:RadComboBox>
              </td>
        <td><asp:ImageButton 
                ID="ImageButton1" runat="server" ImageUrl="~/images/agregar.bmp" 
                Height="16px" Width="18px" />
            </td></tr></table>
        <asp:SqlDataSource ID="dsusuario" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:cnnIntranet %>" 
                    SelectCommand="SELECT [RPE], [Nombre], [Apellido1], [Apellido2], [NombreCompleto], [emailLotusInt], RTRIM(Apellido1) +  ' ' + RTRIM(Apellido2) + ' '  + Nombre As NC FROM [Usuarios] WHERE ([emailLotusInt] IS NOT NULL) ORDER BY NC">
                </asp:SqlDataSource>
        
        <br />
        <telerik:RadGrid ID="rgotros" runat="server" AutoGenerateColumns="False" 
            GridLines="None">   
                    <ClientSettings>
                        <Selecting AllowRowSelect="True" />
                    </ClientSettings>
                    <MasterTableView>   
    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                        <Columns>    
                            <telerik:GridBoundColumn DataField="txtnombre"  UniqueName="txtnombre" HeaderText="">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="temprespseg"  HeaderText="RESPSEG"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkrespseg" runat="server"/>  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="tempatender" HeaderText="ATENDER" >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkatender" runat="server" />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="tempcomentar"  HeaderText="COMENTAR"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkcomentar" runat="server"  />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="tempenterar"  HeaderText="ENTERAR"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkenterar" runat="server"   />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridTemplateColumn UniqueName="temparchivar"  HeaderText="ARCHIVAR"  >  
                                    <ItemTemplate>  
                                        <asp:CheckBox ID="chkarchivar" runat="server"  />  
                                    </ItemTemplate>  
                                </telerik:GridTemplateColumn
                                <telerik:GridButtonColumn Text="Borrar" CommandName="Delete"></telerik:GridButtonColumn>
                            </Columns>   
                    </MasterTableView>   
            </telerik:RadGrid>  
      
      
        <br />
    </asp:Content>
    And here is my code behind VB
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Request("id") = "" Then
                'Response.Redirect("inbox.aspx")
            End If
            If Not IsPostBack Then
                rggrupos.DataSourceID = "dsGrupos"
                dsGrupos.SelectCommand = "SELECT * FROM [usuariosgrupo] Where owner = '" & Request("rpe") & "'"
                Me.rggrupos.DataBind()
            End If
     End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnotro.Click
      
            If MyDataTable.Columns.Count = 0 Then
                MyDataTable.Columns.Add("txtnombre")
            End If
      
            Dim selectedvalue As String = rcbotros.SelectedItem.Text
            MyDataTable.Rows.Add(selectedvalue)
            rgotros.Rebind()
        End Sub
    Protected Sub rgotros_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgotros.ItemCommand
      
            If e.CommandName = "Delete" Then
                Dim txtnombre As String = CType(e.Item, GridDataItem)("txtnombre").Text
                MyDataTable.Rows.Remove(MyDataTable.Select("txtnombre = '" & txtnombre & "'").First())
                rgotros.Rebind()
            End If
      
        End Sub
    Public Property MyDataTable() As DataTable
            Get
                If Session("MyDataTable") Is Nothing Then
                    Session("MyDataTable") = New DataTable()
                End If
                Return CType(Session("MyDataTable"), DataTable)
            End Get
      
            Set(ByVal Value As DataTable)
                Session("MyDataTable") = Value
            End Set
      
        End Property
        Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgotros.NeedDataSource
            rgotros.DataSource = MyDataTable
        End Sub

    The problem is when i try to expand or collapse my grid groups i get an error:

    Mensaje: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
    Línea: 6
    Carácter: 84093
    Código: 0
    URI: http://MatrizTurnadoWeb/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aes-ES%3a1f68db6e-ab92-4c56-8744-13e09bf43565%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.2.713.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aes-ES%3a1814ab69-dbf3-46be-b5e4-1b4e7d85f183%3a16e4e7cd%3aed16cbdc%3ab7778d6c%3a58366029%3af7645509%3a24ee1bba%3a1e771326%3aaa288e2d%3a874f8ea2%3adc7e0bd%3a1569bb5f%3a63b115ed%3a30f1f089%3a19620875%3a490a9d4e
     and the same error hapens with i hit the imagebutton
    any idea could help, thanks alot for your time

    Carlos
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 26 Nov 2010 Link to this post

    Hello Carlos,

    Do note the difference between Advanced and Simple data-binding and rework your implementation along the lines of Advanced data-binding only (this includes removing the call to the grid's DataBind() method from the Page_Load event).


    Regards,
    Tsvetoslav
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top