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

Strange bug when adding templateitem to RadGrid

1 Answer 12 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eran
Top achievements
Rank 1
Eran asked on 20 Aug 2014, 05:14 PM
Here is my grid, When i removed the template button the grid functions well, but when the template button is included the grid does not load well and the ui is somewhat destroyed, all the data appears in a chained string inside a box when the template button is in place:

<telerik:RadGrid OnItemCreated="gvClients_ItemCreated" runat="server" ID="gvClients" ClientSettings-EnablePostBackOnRowClick="true" CellSpacing="0" GridLines="None" Skin="Glow" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" OnSelectedIndexChanged="gvClients_SelectedIndexChanged" OnDataBound="gvClients_DataBound" AutoGenerateColumns="False">
    <ClientSettings>
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
    <MasterTableView DataKeyNames="id" DataSourceID="SqlDataSource1" HierarchyLoadMode="Client">
        <Columns>
            <telerik:GridBoundColumn DataField="seniorId" DataType="System.Int32" FilterControlAltText="Filter seniorId column" HeaderText="seniorId" SortExpression="seniorId" UniqueName="seniorId" Visible="False">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="id" DataType="System.Int32" FilterControlAltText="Filter id column" HeaderText="תעדות זהות" ReadOnly="True" SortExpression="id" UniqueName="id">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="password" FilterControlAltText="Filter password column" HeaderText="סיסמא" SortExpression="password" UniqueName="password">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="fName" FilterControlAltText="Filter fName column" HeaderText="שם פרטי" SortExpression="fName" UniqueName="fName">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="lName" FilterControlAltText="Filter lName column" HeaderText="שם משפחה" SortExpression="lName" UniqueName="lName">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="mPhone" FilterControlAltText="Filter mPhone column" HeaderText="מספר טלפון" SortExpression="mPhone" UniqueName="mPhone">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="address" FilterControlAltText="Filter address column" HeaderText="כתובת" SortExpression="address" UniqueName="address">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="sc" DataType="System.Byte" FilterControlAltText="Filter sc column" HeaderText="sc" SortExpression="sc" UniqueName="sc" Visible="False">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="email" FilterControlAltText="Filter email column" HeaderText="אימייל" SortExpression="email" UniqueName="email">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="dateJoined" DataFormatString="{0:HH:mm dd-MM-yyyy}" DataType="System.DateTime" FilterControlAltText="Filter dateJoined column" HeaderText="תאריך הצטרפות" SortExpression="dateJoined" UniqueName="dateJoined">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="contract" FilterControlAltText="Filter contract column" HeaderText="קובץ חוזה" SortExpression="contract" UniqueName="contract">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="הורד קובץ" UniqueName="downloadbutton">
                <ItemTemplate>
                    <telerik:RadButton ID="btnDownload" runat="server" Skin="Glow" Text="הורד קובץ" CommandArgument="<%#Container.ItemIndex %>" OnCommand="btnDownload_Command">
                    </telerik:RadButton>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
        <PagerStyle AlwaysVisible="True" />
    </MasterTableView>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 21 Aug 2014, 12:23 PM
Hi Eran,

I was not able to replicate such an issue at my end. Please take a look at the sample code snippet, make sure you have no css set that effects the styling.

ASPX:
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<telerik:RadGrid runat="server" ID="rgrdSample" Skin="Glow" DataSourceID="dsGrid" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False">
    <ClientSettings>
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
    <MasterTableView DataKeyNames="OrderID">
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="EmployeeID" HeaderText="EmployeeID" UniqueName="EmployeeID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Download" UniqueName="downloadbutton">
                <ItemTemplate>
                    <telerik:RadButton ID="btnDownload" runat="server" Skin="Glow" Text="Download" CommandArgument="<%#Container.ItemIndex %>" OnCommand="btnDownload_Command">
                    </telerik:RadButton>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
        <PagerStyle AlwaysVisible="True" />
    </MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="dsGrid" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT  * FROM [Orders]"></asp:SqlDataSource>

C#:
protected void btnDownload_Command(object sender, CommandEventArgs e)
{
    Label1.Text = e.CommandArgument.ToString();
}

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