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

[Solved] Radgrid displays data only after the first postback ...

1 Answer 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Krzysztof
Top achievements
Rank 1
Krzysztof asked on 21 Dec 2009, 01:10 PM
Hello. I have the following issue, the data in the grid are displayed correctly but after the first refresh the page. How to make that data were displayed in the grid as soon as the page loads?

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="raport_urlopy.aspx.vb" Inherits="raport_urlopy" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Intranet</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
      
    <div class="gora"><href="default.aspx"><img src="gfx/intranet2.gif" alt="Intranet" border="0"></a> 
    </div> 
      
    <div class="menu">  
   <!-- #include file="inc-menu.aspx "-->      
        
    </div> 
      
    <div class="srodek">  
      
     
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        </telerik:RadAjaxManager> 
      
       <div style="text-align:left">  
       <div class="pasek">Raport o urlopach</div> 
       <table border="0">  
       <tr> 
       <td align="right" valign="middle">Rok:</td><td align="left" valign="middle">  
         
         <asp:DropDownList ID="ddl_rok" runat="server" DataSourceID="sql_rok"   
                            DataTextField="kp_rok" DataValueField="kp_rok" Width="258px" AutoPostBack="True">  
         </asp:DropDownList> 
         
       </td> 
       </tr> 
         
       <tr> 
       <td align="right" valign="middle">DziaÅ‚:</td><td align="left" valign="middle">  
                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="sql_dzial"   
                            DataTextField="nazdz" DataValueField="id" Width="258px" AutoPostBack="True"></asp:DropDownList></td>  
       </tr> 
                
       </table> 
         
    </div> 
         
            <asp:TextBox ID="txt_idp" runat="server" Visible="False"></asp:TextBox> 
         
        <br />      
       
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="sql_urlopy_glowne"   
            GridLines="None" AllowSorting="True" ShowGroupPanel="True" Skin="Hay" allow> 
        
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="idp" DataSourceID="sql_urlopy_glowne">  
                <DetailTables> 
                    <telerik:GridTableView AutoGenerateColumns="false" DataKeyNames="idp" DataSourceID="sql_urlopy_pomoc" Width="100%" runat="server">  
                                            
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="idp" MasterKeyField="idp" /> 
                        </ParentTableRelation> 
                        <Columns> 
                            <telerik:GridBoundColumn SortExpression="opis" HeaderText="Typ" DataField="opis" UniqueName="opis">  
                            </telerik:GridBoundColumn> 
                              
                             <telerik:GridBoundColumn SortExpression="pdn" HeaderText="Od" DataField="pdn" UniqueName="pdn"  DataFormatString="{0:dd-MM-yyyy}">  
                            </telerik:GridBoundColumn> 
                              
                              <telerik:GridBoundColumn SortExpression="odn" HeaderText="Do" DataField="odn" UniqueName="odn"  DataFormatString="{0:dd-MM-yyyy}">  
                            </telerik:GridBoundColumn> 
                        </Columns> 
                                     
                    </telerik:GridTableView> 
                </DetailTables> 
 
<ExpandCollapseColumn Visible="True"></ExpandCollapseColumn> 
 
                <Columns> 
                    <telerik:GridBoundColumn DataField="idp" DataType="System.Int32" HeaderText="idp" 
                        ReadOnly="True" SortExpression="idp" UniqueName="idp" Visible="false">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="naz" HeaderText="Nazwisko" SortExpression="naz" UniqueName="naz">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="IL_UrlopWymiar" DataType="System.Int16" HeaderText="Wymiar" 
                        SortExpression="IL_UrlopWymiar" UniqueName="IL_UrlopWymiar">  
                    </telerik:GridBoundColumn> 
                     
                    <telerik:GridBoundColumn DataField="KD_IL_UrlopPrzysl" DataType="System.Int16" HeaderText="PrzysÅ‚ugujÄ…cy" 
                        SortExpression="KD_IL_UrlopPrzysl" UniqueName="KD_IL_UrlopPrzysl">  
                    </telerik:GridBoundColumn> 
                      
                     <telerik:GridBoundColumn DataField="IL_UrlopDoWyk" DataType="System.Int16" HeaderText="PozostaÅ‚y" 
                        SortExpression="IL_UrlopDoWyk" UniqueName="IL_UrlopDoWyk">  
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
            <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True"   
                ReorderColumnsOnClient="True">  
                <Selecting AllowRowSelect="True" /> 
            </ClientSettings> 
        </telerik:RadGrid> 
                            
        <br /><br /><br /> 
                     
    </div> 
      
      
    <asp:SqlDataSource ID="sql_dzial" runat="server"   
        ConnectionString="<%$ ConnectionStrings:Polaczenie-Portal %>"   
        SelectCommand="proc_wczytaj_dzialy" SelectCommandType="StoredProcedure">  
     
       <SelectParameters> 
       
           <asp:FormParameter DefaultValue="122" FormField="txt_idp" Name="idpracownika"   
               Type="Int32" /> 
       
       
       </SelectParameters>        
              
     </asp:SqlDataSource> 
     
    <asp:SqlDataSource ID="sql_urlopy_glowne" runat="server"   
        ConnectionString="<%$ ConnectionStrings:Polaczenie-Portal %>"   
        SelectCommand="proc_pokaz_ilosc_urlopow_w_dziale"   
        SelectCommandType="StoredProcedure">  
          
        <SelectParameters> 
        
            <asp:ControlParameter ControlID="DropDownList1" Name="id_dzial"   
                PropertyName="SelectedValue" Type="Int32" /> 
          
             <asp:ControlParameter ControlID="ddl_rok" Name="rok"   
                PropertyName="SelectedValue" Type="Int32" />    
          
            <asp:SessionParameter Name="idpracownika" SessionField="idpracownika" Type="string" />                                        
          
        </SelectParameters> 
          
    </asp:SqlDataSource> 
   
    <asp:SqlDataSource ID="sql_urlopy_pomoc" ConnectionString="<%$ ConnectionStrings:Polaczenie-Portal %>" 
        ProviderName="System.Data.SqlClient" SelectCommand="select pracownik as idp, opis, pdn, odn from poza_biurem join urlopy on poza_biurem.id = urlopy.id_poza_biurem where pracownik = @idp and aktywny=1" 
        runat="server">  
        <SelectParameters> 
            <asp:SessionParameter Name="idp" SessionField="idp" Type="string" /> 
        </SelectParameters> 
        </asp:SqlDataSource> 
          
        <asp:SqlDataSource ID="sql_rok" ConnectionString="<%$ ConnectionStrings:Polaczenie-Portal %>" 
            ProviderName="System.Data.SqlClient" SelectCommand="select distinct kp_rok from kd_urlopy2" SelectCommandType="Text" 
            runat="server"></asp:SqlDataSource> 
     
      
    </form> 
</body> 
</html> 
 

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 22 Dec 2009, 07:26 AM
Hello Krzysztof,

I think the problem comes from the way you bind your controls, when you bind your RadGrid you used stored procedure with parameters which you get from dropdown lists. I assume your dropdowns are populated too late and they don’t have any selectedvalues when the RadGrid is bound.
You could verify that by changing RadGrid with some of the asp.net standard container control, for example ListView.
Or you could open a formal support ticket from your Telerik account and attach a ZIP file with your code behind file and database files. It will be helpful if you could send me a runnable simple project so we could debug it locally and find a proper resolution for you.


Regards,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Krzysztof
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or