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

[Solved] RadGrid not doing postback

4 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sara
Top achievements
Rank 1
sara asked on 23 Apr 2009, 08:13 AM
I have a radgrid on my aspx page, andas far as I can see the ajax component isn't working. The master table has a detail row (sub table) to drill into. When I click on the + sign, the query is being run (as I can see in SQL profiler) but the content isn't being displayed. This is also happening with the paging, I click on the next page icon and it isnt paging. I do have an Ajax scriptmanager on the page.
 
Thank you for your help.

The code for my grid is below (the dataset for the main table is being set in the code behind and is functioning):

  <rad:RadGrid id="radPOS" AutoGenerateColumns="false"   
                AllowPaging="true" 
                Skin="WebBlue" 
                GridLines="Both" 
                OnDetailTableDataBind="RadPOS_DetailTableDataBind" runat="server"   
  Width="970px">  
    
 
 
<MasterTableView  DataKeyNames="PurchaseOrderId"           
                    HierarchyLoadMode="ServerOnDemand">  
 
 
  <detailtables> 
        <rad:GridTableView runat="server" ClientDataKeyNames="PurchaseOrderID" DataKeyNames="PurchaseOrderID" HierarchyLoadMode="Client"   
            DataSourceID="SQLDataSource2" AutoGenerateColumns="false">  
             <ParentTableRelation> 
                            <rad:GridRelationFields DetailKeyField="PurchaseOrderID" MasterKeyField="PurchaseOrderID" /> 
                        </ParentTableRelation> 
 
            <Columns> 
            <rad:GridBoundColumn DataField="InventoryItem" HeaderText="Item"   
                    UniqueName="InventoryItem">  
                      
                </rad:GridBoundColumn> 
               <rad:GridBoundColumn DataField="Description" HeaderText="Description"   
                    UniqueName="Description">  
                </rad:GridBoundColumn> 
                <rad:GridBoundColumn DataField="VendorItemNumber" HeaderText="Vendor Part#"   
                    UniqueName="VendorItemNumber">  
                </rad:GridBoundColumn> 
                <rad:GridBoundColumn DataField="Quantity" HeaderText="Quantity"   
                    UniqueName="column1">  
                </rad:GridBoundColumn>                  
                <rad:GridBoundColumn DataField="UoM" HeaderText="Units"   
                    UniqueName="Uom">  
                </rad:GridBoundColumn> 
                <rad:GridBoundColumn DataField="Price" DataFormatString="{0:c}"   
                    HeaderText="Price" UniqueName="column">  
                </rad:GridBoundColumn> 
                <rad:GridTemplateColumn HeaderText="Line Total">  
                <ItemTemplate> 
                <asp:Label ID="lblPrice" runat="server" Text='<%# string.format("{0:c}",databinder.eval(container,"dataitem.quantity") * databinder.eval(container,"Dataitem.price")) %>'></asp:Label> 
                </ItemTemplate> 
                </rad:GridTemplateColumn> 
                 
            
          
            </Columns> 
        </rad:GridTableView> 
          
    </detailtables> 
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn visible="True">  
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
      
        <rad:GridBoundColumn DataField="PurchaseOrderID" DataType="System.Int64"   
            HeaderText="PurchaseOrderID" ReadOnly="True" SortExpression="PurchaseOrderID"   
            UniqueName="PurchaseOrderID" Visible="False">  
        </rad:GridBoundColumn> 
        <rad:GridTemplateColumn ItemStyle-Width="40px" HeaderStyle-Width="40px">  
        <ItemTemplate> 
        <href='<%# "viewpo.aspx?PurchaseOrder=" & databinder.eval(container,"dataitem.PurchaseOrderID") %>' onclick="javascript:window.print();" target="_blank" ><img src="images/printer.png" border="0" alt="Print This PO" /></a>   
        </ItemTemplate> 
        </rad:GridTemplateColumn> 
        <rad:GridTemplateColumn ItemStyle-Width="35px" HeaderStyle-Width="35px">  
        <ItemTemplate> 
        <href='javascript:OpenWindow(<%# databinder.eval(container,"dataitem.PurchaseOrderID")%>)'><img src="images/basket_go.png" border="0" alt="Receive this PO" /></a>  
        </ItemTemplate> 
        </rad:GridTemplateColumn> 
        <rad:GridTemplateColumn ItemStyle-Width="35px" HeaderStyle-Width="35px">  
        <ItemTemplate> 
         <href='<%#"FileUpload.aspx?&PO=" & databinder.eval(container,"dataitem.PurchaseOrderID") & "&height=300&width=300&TB_iframe=true"%>' class="thickbox" ><img alt="files" border="0" src="images/folder_explore.png"></a> 
        </ItemTemplate> 
        </rad:GridTemplateColumn> 
        <rad:GridTemplateColumn ItemStyle-Width="35px" HeaderStyle-Width="35px">          
        <ItemTemplate> 
         <href='<%#"EnterEmail.htm?&PO=" & databinder.eval(container,"dataitem.PurchaseOrderID") & "&height=300&width=300&TB_iframe=true"%>' class="thickbox" ><img alt="email" border="0" src="images/email.png"></a> 
        </ItemTemplate> 
        </rad:GridTemplateColumn> 
        <rad:GridTemplateColumn ItemStyle-Width="35px" HeaderStyle-Width="35px">          
        <ItemTemplate> 
        <href='<%#"EnterFax.htm?&PO=" & databinder.eval(container,"dataitem.PurchaseOrderID") & "&height=300&width=300&TB_iframe=true"%>' class="thickbox" ><img alt="fax" border="0" src="images/page_white_go.png"></a>    
        </ItemTemplate> 
        </rad:GridTemplateColumn> 
          <rad:GridTemplateColumn HeaderText="PO Number" SortExpression="PONumber">  
        <ItemTemplate> 
        <asp:HyperLink id="lnkPo" runat="server" NavigateUrl='<%# "newpurchaseorder.aspx?mode=edit&PO=" & databinder.eval(container,"dataitem.PurchaseOrderID")%>'  Target="_blank" Text='<%# bind("PONumber") %>'></asp:HyperLink> 
        </ItemTemplate> 
        </rad:GridTemplateColumn> 
 
         
          
         
        <rad:GridBoundColumn DataField="OrderTotal" DataType="System.Double"   
            HeaderText="Order Total" ReadOnly="True" SortExpression="OrderTotal"   
            UniqueName="OrderTotal" DataFormatString="{0:c}">  
        </rad:GridBoundColumn> 
        <rad:GridBoundColumn DataField="RequisitionedBy"   
            HeaderText="RequisitionedBy" SortExpression="RequisitionedBy"   
            UniqueName="RequisitionedBy">  
        </rad:GridBoundColumn> 
        <rad:GridBoundColumn DataField="PurchaseOrderDate"   
            DataType="System.DateTime" HeaderText="PO Date"   
            SortExpression="PurchaseOrderDate" UniqueName="PurchaseOrderDate" DataFormatString="{0:d}">  
        </rad:GridBoundColumn> 
        <rad:GridBoundColumn DataField="OrderStatus" HeaderText="OrderStatus"   
            SortExpression="OrderStatus" UniqueName="OrderStatus">  
        </rad:GridBoundColumn> 
        <rad:GridBoundColumn DataField="LastUpdated" DataType="System.DateTime"   
            HeaderText="Last Updated" SortExpression="LastUpdated" UniqueName="LastUpdated">  
        </rad:GridBoundColumn> 
          
    </Columns> 
</MasterTableView> 
 
 <ClientSettings AllowGroupExpandCollapse="True" > 
                    <Selecting AllowRowSelect="true" /> 
                </ClientSettings> 
 
</rad:RadGrid></ContentTemplate></asp:UpdatePanel> 
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"   
        ConnectionString="<%$ ConnectionStrings:BannerSmokedFishConnectionString2 %>"   
        SelectCommand="SELECT * FROM [Purchase_Order_Items] WHERE ([PurchaseOrderID] = @PurchaseOrderID)">  
        <SelectParameters> 
        <asp:SessionParameter Name="PurchaseOrderID" SessionField="PurchaseOrderID" Type="Int64" /> 
              
        </SelectParameters> 
    </asp:SqlDataSource> 
<rad:RadAjaxManager runat="server">  
    <ajaxsettings> 
        <rad:AjaxSetting AjaxControlID="SqlDataSource1">  
            <updatedcontrols> 
                <rad:AjaxUpdatedControl ControlID="radPOS" /> 
            </updatedcontrols> 
        </rad:AjaxSetting> 
        <rad:AjaxSetting AjaxControlID="radPOS">  
        </rad:AjaxSetting> 
        <rad:AjaxSetting AjaxControlID="SqlDataSource2">  
        </rad:AjaxSetting> 
    </ajaxsettings> 
</rad:RadAjaxManager> 

4 Answers, 1 is accepted

Sort by
0
sara
Top achievements
Rank 1
answered on 23 Apr 2009, 08:58 AM
Also, I am using the Q# 2008 controls. I have no other controls on the page.

Here is where I am setting the RadGrid main table datasource:

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

radPOS.DataSource = getPOByStatus(

"All")

 

radPOS.DataBind()

 

End Sub

 




Thank you again for your help.
0
Princy
Top achievements
Rank 2
answered on 23 Apr 2009, 10:04 AM
Hi,

Try setting both the  AjaxControlID and AjaxUpdatedControl to the grid in the RadAjaxManger



<telerik:AjaxSetting AjaxControlID="radPOS"
                    <UpdatedControls> 
                     <telerik:AjaxUpdatedControl ControlID="radPOS" LoadingPanelID="LoadingPanel1"></telerik:AjaxUpdatedControl> 
                    </UpdatedControls> 
</telerik:AjaxSetting>


Thanks,
Princy

0
sara
Top achievements
Rank 1
answered on 23 Apr 2009, 03:57 PM
That did not work, what is the loading panel id?
0
Sebastian
Telerik team
answered on 27 Apr 2009, 07:33 AM
Hello sara,

I reviewed your code and here are my findings:

  1. You assign data source control for the detail table and at the same time attach the DetailTableDataBind event of the grid to populate the child table. Note that you should either use the declarative approach with parent table relations or programmatic binding with DetailTableDataBind handling as demonstrated in these examples:

    http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarativerelations/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx

    http://www.telerik.com/help/aspnet-ajax/grdhierarchicaldatabindingusingneeddatasource.html
    http://www.telerik.com/help/aspnet-ajax/grdhierarchicaldatabindingusingdetailtabledatabind.html
  2. You bind the grid instance on each page load with simple binding with DataBind() calls. Hierarchical grids require advanced binding with NeedDataSource event handling or assigning data source controls as shown in these demos:

    http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/hierarchyloadmodemixed/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx
  3. The loading panel id is the id of the RadAjaxLoadingPanel on the page that will be shown while the grid instance updates itself during an ajax request. More information on this subject can be found here:

    http://demos.telerik.com/aspnet-ajax/ajax/examples/loadingpanel/loadingimages/defaultcs.aspx 
    http://www.telerik.com/help/aspnet-ajax/ajxloadingpanel.html

    Finally, you may be interested in learning more about how to optimize your support resources searches from the resources linked in the footer of this message.

Regards,

Sebastian

the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
sara
Top achievements
Rank 1
Answers by
sara
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or