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

[Solved] Grid problem - work around?

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chuck Harrington
Top achievements
Rank 1
Chuck Harrington asked on 05 Feb 2013, 03:20 PM
I have a situation that I wonder if anyone can suggest or point me to a solution that solves my problem.
I want to display the radcombobox so the user can select a date, which will return a set of records from a database.
The problem is that the grid does have any datasource until then and therefore does not display.
The combobox is in a commanditem template and does not display.  Would it be better to load the grid with dummy records(all zeros and nulls) or is there a better solution.
I just need to display the radcombobox.  Any suggestions will be appreciated.  The HTML is below.
<
telerik:RadGrid ID="TimesheetGrid" runat="server" AutoGenerateColumns="false" EnableLinqExpressions="false" GridLines="None">
        <MasterTableView CommandItemDisplay="Top" AllowPaging="false" PageSize="15">
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
            </EditFormSettings>
            <CommandItemTemplate>
                <table>
                    <tr>
                        <td style="width:10%">                          
                            <telerik:RadComboBox ID="cboPayPeriod" runat="server" AutoPostBack="true" OnSelectedIndexChanged="cboPayPeriod_SelectedIndexChanged"></telerik:RadComboBox>
                        </td>
                        <td style="width:40%">
                            <asp:LinkButton ID="cmdInsert" runat="server" CommandName="InitInsert" Font-Underline="True" ForeColor="White">Insert New Timesheets Record</asp:LinkButton>
                        </td>
                        <td style="width:30%">
                            <asp:LinkButton ID="cmdUpdateAll" runat="server" CommandName="UpdateEdited" Font-Underline="True" ForeColor="White">Update Timesheet</asp:LinkButton>
                        </td>
                    </tr>
                </table>
            </CommandItemTemplate>
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
            <Columns>
                <telerik:GridDateTimeColumn DataField="WorkDate" HeaderText="Work Date" UniqueName="WorkDate" DataFormatString="{0:MM/dd/yy}"
                    HeaderStyle-Width="100px" HeaderStyle-HorizontalAlign="Center" AllowFiltering="false">
                </telerik:GridDateTimeColumn>
                <telerik:GridBoundColumn DataField="Shift" HeaderText="Shift" ItemStyle-Width="25px" HeaderStyle-Width="25px" AllowFiltering="False"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Reg" HeaderText="Reg" ItemStyle-Width="35px" AllowSorting="True" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ShftHrs" HeaderText="Shift Hrs" ItemStyle-Width="35px" AllowSorting="True" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="OT" HeaderText="OT" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Vac36" HeaderText="Vac 36 Hrs" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Vac40" HeaderText="Vac 40 Hrs" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Vac48" HeaderText="Vac 48 Hrs" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Sick36" HeaderText="Sick 36 Hrs" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Sick40" HeaderText="Sick 40 Hrs" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Sick48" HeaderText="Sick 48 Hrs" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Exc_Absence" HeaderText="Exc Abs Hrs" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Holiday_Worked" HeaderText="Holiday Worked" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Holiday_Not_Worked" HeaderText="Holiday Not Worked" ItemStyle-Width="35px" AllowFiltering="False" DataFormatString="{0:##.0}"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Comments" HeaderText="Comment" ItemStyle-Width="135px" AllowFiltering="False"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Additional_Comment" HeaderText="Additional Comment" ItemStyle-Width="135px" AllowFiltering="False"></telerik:GridBoundColumn>
                <telerik:GridTemplateColumn DataField="Five" HeaderText="5%" AllowFiltering="false">
                    <ItemTemplate>
                        <asp:CheckBox ID="chkFive" runat="server" Checked='<%#Bind("Five")%>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn DataField="Ten" HeaderText="10%" AllowFiltering="false">
                    <ItemTemplate>
                        <asp:CheckBox ID="chkTen" runat="server" Checked='<%#Bind("Ten")%>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Feb 2013, 04:16 AM
Hi,

One suggestion is to bind the RadGrid using an empty DataSource for the first time when page loads. Please try the following code snipet.

C#:
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TimesheetGrid.DataSource = String.Empty;
        }
    }

Thanks,
Shinu.
0
Chuck Harrington
Top achievements
Rank 1
answered on 06 Feb 2013, 01:56 PM
Thanks Shinu.  As always right on the mark.  As a regular visitor to the forums, I appreciate your "spot-on" responses to questions. I have picked up many valuable techniques from your posts. Thanks again.
Tags
Grid
Asked by
Chuck Harrington
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Chuck Harrington
Top achievements
Rank 1
Share this question
or