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

Radgrid problem

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zsh
Top achievements
Rank 1
Zsh asked on 11 Dec 2012, 04:18 PM
Hi

I have a radgrid using editmode popup. 
when no record in grid(data source is empty) and click Inset new records ,the grid is not visible, only a single line
even I  use OnNeedDatasourse event and write the code to fill grid from SQL inside the event But not work!
Please help me
<telerik:RadGrid ID="RadGrid3"   runat="server"   AutoGenerateEditColumn="True" ShowFooter="true"
            GridLines="None" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True"    OnItemDeleted="RadGrid2_ItemDeleted"
        OnItemInserted="RadGrid2_ItemInserted" 
        OnItemUpdated="RadGrid2_ItemUpdated" AutoGenerateDeleteColumn="True" 
        Skin="Office2007" 
        AllowSorting="True" AutoGenerateColumns="False"
        ShowStatusBar="True" onitemcommand="RadGrid3_ItemCommand" 
        
        oninsertcommand="RadGrid3_InsertCommand" 
        onitemdatabound="RadGrid3_ItemDataBound" 
        onselectedindexchanged="RadGrid3_SelectedIndexChanged" 
        ondatabound="RadGrid3_DataBound" onupdatecommand="RadGrid3_UpdateCommand" onneeddatasource="RadGrid3_NeedDataSource" 
            DataSourceID="SqlDataSource3" Enabled="False" 
               öndatabinding="RadGrid3_DataBinding">
        <ClientSettings EnablePostBackOnRowClick="True">
                 
            <Selecting AllowRowSelect="True" />
             <ClientEvents  önRowDblClick="RowDblClick"></ClientEvents>
        </ClientSettings>
        <MasterTableView  CommandItemDisplay="Top"  EditMode="PopUp"  
            DataKeyNames="WorkID" DataSourceID="SqlDataSource3" >
            <CommandItemSettings AddNewRecordText="Insert" RefreshText="Refresh"   />
            <Columns>
                <telerik:GridBoundColumn DataField="MachinaryMainCode" 
                    HeaderText="MachinaryMainCode" SortExpression="MachinaryMainCode" 
                    UniqueName="MachinaryMainCode" Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UserDate" DataType="System.DateTime" 
                    HeaderText="UserDate" SortExpression="UserDate" 
                    UniqueName="UserDate" Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="WorkDuration" DataType="System.Int32" 
                    HeaderText="time" SortExpression="WorkDuration" 
                    UniqueName="WorkDuration">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="WorkID" DataType="System.Int32" 
                    HeaderText="WorkID" SortExpression="WorkID" 
                    UniqueName="WorkID" ReadOnly="True" Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="URID" 
                    HeaderText="URID" SortExpression="URID" 
                    UniqueName="URID" DataType="System.Int32" ReadOnly="True" Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UnUsaReason" 
                    HeaderText="UnUsaReason" SortExpression="UnUsaReason" 
                    UniqueName="UnUsaReason">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="USID" DataType="System.Int32" 
                    HeaderText="USID" SortExpression="USID" 
                    UniqueName="USID" ReadOnly="True" Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UsageName" 
                    HeaderText="UsageName" SortExpression="UsageName" 
                    UniqueName="UsageName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="StatusID" DataType="System.Int32" 
                    HeaderText="StatusID" ReadOnly="True" SortExpression="StatusID" 
                    UniqueName="StatusID" Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="StatusName" HeaderText="StatusName" 
                    SortExpression="StatusName" UniqueName="StatusName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="EPID" DataType="System.Int32" 
                    HeaderText="EPID" ReadOnly="True" SortExpression="EPID" UniqueName="EPID" 
                    Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="EquipmentName" HeaderText="EquipmentName" 
                    SortExpression="EquipmentName" UniqueName="EquipmentName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ARID" DataType="System.Int32" 
                    HeaderText="ARID" ReadOnly="True" SortExpression="ARID" UniqueName="ARID" 
                    Visible="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AreaName" HeaderText="AreaName" 
                    SortExpression="AreaName" UniqueName="AreaName">
                </telerik:GridBoundColumn>
                                                                          </tr>
                        </tr>
                    
                    </table>
                    <table style="width: 100%">
                    <tr>
                                       </tr>
                        <tr>
                            <td align="right">
                                <asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Refresh" %>'
                                CommandName='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" ValidationGroup="ValidationGroup"  >
                                </asp:Button
                                <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">
                                </asp:Button>
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
        <PopUpSettings Modal="True" />
    </EditFormSettings>
      
        </MasterTableView>
        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
    </telerik:RadGrid>
 <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CMMSConnectionString2 %>" 
              
        SelectCommand="SELECT ML.MachinaryMainCode, WI.UserDate, WI.WorkDuration, WI.WorkID, UR.ID AS URID, UR.UnUsaReason, US.ID AS USID, US.UsageName, MS.StatusID, MS.StatusName, EP.ID AS EPID, EP.EquipmentName, Ar.ID AS ARID, Ar.AreaName, WI.WorkKilometer, CN.ContractorID, CN.CompanyName, CN.Name + ' ' + CN.Family AS Name, WI.UnUsaReasonID, CN.ContractorType, WI.DisciplineID, Discipline.DisciplineName FROM Discipline RIGHT OUTER JOIN WorkInfo AS WI ON Discipline.ID = WI.DisciplineID RIGHT OUTER JOIN MachinList AS ML LEFT OUTER JOIN MachineryName AS MN ON ML.MachinaryNameID = MN.ID LEFT OUTER JOIN MachineryModel AS MM ON ML.MachinaryModelID = MM.ID LEFT OUTER JOIN MachineryType AS MT ON ML.MachinaryTypeID = MT.ID ON WI.MachinID = ML.ID LEFT OUTER JOIN UnUsaReason AS UR ON WI.UnUsaReasonID = UR.ID LEFT OUTER JOIN UsageShop AS US ON WI.UsageShopID = US.ID LEFT OUTER JOIN MachinStatus AS MS ON WI.StatusID = MS.StatusID LEFT OUTER JOIN Equipment AS EP ON WI.EquipmentID = EP.ID LEFT OUTER JOIN Area AS Ar ON WI.AreaID = Ar.ID LEFT OUTER JOIN Contractor AS CN ON WI.ContractorID = CN.ContractorID WHERE (ML.ID = @ID) AND (WI.UserDate = @UserDate or WI.UserDate is null )" 
        onselected="SqlDataSource3_Selected">
            <SelectParameters>
                <asp:ControlParameter ControlID="RadGrid1" Name="ID" 
                    PropertyName="SelectedValues['ID']" />
                <asp:ControlParameter ControlID="DatePicker1" Name="UserDate" 
                    PropertyName="Date" Type="DateTime" />
            </SelectParameters>
        </asp:SqlDataSource>
.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Dec 2012, 04:08 AM
Hi,

After inspecting your code I found that you are binding the grid both using declarative and NeedDataSource event. Try binding the grid with any one of these methods.

Thanks,
Shinu.
Tags
Grid
Asked by
Zsh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or