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

Problem with telerik:GridTemplateColumn

14 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sajjad A.
Top achievements
Rank 1
Sajjad A. asked on 13 Mar 2014, 08:32 AM
Hello guys,

i'm having problem with gridtempletecolumn, when i add boundcolums the data shown properly but when i use templetecolum it does not show the data, can any one solve my problem.

check images below for more clearification

14 Answers, 1 is accepted

Sort by
0
Jeffrey
Top achievements
Rank 1
answered on 13 Mar 2014, 08:36 AM
Could you show come of your code?
0
Sajjad A.
Top achievements
Rank 1
answered on 13 Mar 2014, 08:43 AM
<telerik:RadGrid ID="GVSeries" GridLines="None" runat="server" AllowAutomaticDeletes="True"
                            AllowAutomaticInserts="true" AllowFilteringByColumn="true" AllowSorting="true" PageSize="10" Skin="Default" OnItemDeleted="GVSeries_ItemDeleted" OnItemInserted="GVSeries_ItemInserted"
                            OnItemUpdated="GVSeries_ItemUpdated"  OnPreRender="GVSeries_PreRender" AllowAutomaticUpdates="True" AllowPaging="True"
                            AutoGenerateColumns="False" Width="100%" OnBatchEditCommand="GVSeries_BatchEditCommand" ItemStyle-Font-Size="Larger" HeaderStyle-Font-Size="Larger" CommandItemStyle-Font-Size="Larger" Font-Size="Larger">
                            <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="SeriesID"
                                HorizontalAlign="NotSet" EditMode="Batch" AutoGenerateColumns="False">
                                <BatchEditingSettings EditType="row" OpenEditingEvent="Click" SaveAllHierarchyLevels="false" />
                                <SortExpressions>
                                    <telerik:GridSortExpression FieldName="SeriesID" SortOrder="Ascending" />
                                </SortExpressions>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="ElementID" HeaderStyle-Width="50px" HeaderText="ElementID" SortExpression="ElementID"
                                     UniqueName="ElementID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Title" HeaderStyle-Width="50px" HeaderText="Title" SortExpression="Title"
                                        UniqueName="Title">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Description" HeaderStyle-Width="50px" HeaderText="Description" SortExpression="Description"
                                        UniqueName="Description">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Sequence" HeaderStyle-Width="50px" ItemStyle-Wrap="true" HeaderText="Sequence" SortExpression="Sequence"
                                        UniqueName="Sequence">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="SeriesTypeID" HeaderStyle-Width="50px" ItemStyle-Wrap="true" HeaderText="SeriesTypeID" SortExpression="SeriesTypeID"
                                        UniqueName="SeriesTypeID">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Stack" HeaderStyle-Width="50px" ItemStyle-Wrap="true" HeaderText="Stack" SortExpression="Stack"
                                        UniqueName="Stack">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Color" HeaderStyle-Width="50px" ItemStyle-Wrap="true" HeaderText="Color" SortExpression="Color"
                                        UniqueName="Color">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="FunctionName" HeaderStyle-Width="50px" ItemStyle-Wrap="true" HeaderText="FunctionName" SortExpression="FunctionName"
                                        UniqueName="FunctionName">
                                    </telerik:GridBoundColumn>
                                  
                                   <telerik:GridTemplateColumn>
                                        <ItemTemplate>
                                            <%# Eval("Show_As_Parameter")%>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:CheckBox Text="text" runat="server" />
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridButtonColumn ConfirmText="Are you sure you want delete this reord?" ConfirmDialogType="RadWindow"
                                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="30px" ButtonType="ImageButton"
                                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                    </telerik:GridButtonColumn>
                                     <%--<telerik:GridEditCommandColumn FooterText="EditCommand footer" UniqueName="EditCommandColumn"
                                        HeaderText="Edit" HeaderStyle-Width="100px" UpdateText="Update">
                                    </telerik:GridEditCommandColumn>--%>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings AllowKeyboardNavigation="false">
                                <Selecting AllowRowSelect="true"></Selecting>
                            </ClientSettings>
                        </telerik:RadGrid>
0
Sajjad A.
Top achievements
Rank 1
answered on 13 Mar 2014, 08:44 AM
when i add this code it does not show any data as shown in image:

<telerik:GridTemplateColumn>
                                        <ItemTemplate>
                                            <%# Eval("Show_As_Parameter")%>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:CheckBox Text="text" runat="server" />
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
0
Jeffrey
Top achievements
Rank 1
answered on 13 Mar 2014, 08:50 AM
First off, you are missing the parameter datafield in your templatecolumn. 
 <%# Eval("Show_As_Parameter")%>
It isn't possible to find data since there is none.
For myself I used the following example to make my own version work: 
https://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultvb.aspx?#qsf-demo-source
0
Sajjad A.
Top achievements
Rank 1
answered on 13 Mar 2014, 08:56 AM
i also tries that, added the datafield but the same result still.
0
Jeffrey
Top achievements
Rank 1
answered on 13 Mar 2014, 08:58 AM
Did you also at the other values as shown in example?
Also did you bind your datasource or do you bind from codebehind?
0
Sajjad A.
Top achievements
Rank 1
answered on 13 Mar 2014, 09:00 AM
i request you guys to kindly have another look at my images and code one more time for clear understanding of my problem, my whole project is stuck due to this single problem.

help me please.
0
Sajjad A.
Top achievements
Rank 1
answered on 13 Mar 2014, 09:01 AM
yes on all values, and the datta is bound from codebehind.
everything is working fine until i add templetecolumn, as soon as i add templete column the grid goes wild.
0
Princy
Top achievements
Rank 2
answered on 13 Mar 2014, 09:51 AM
Hi Sajjad,

I guess you are binding the grid using simple data binding. Please make sure that your  RadGrid must be bound using declarative data sources or through the NeedDataSource event. When using declarative data sources or the NeedDataSource event, RadGrid can automatically accommodate the appropriate database operations without the need for you explicitly handle any sorting, paging, grouping, and so on. When you have complex operation like Inserting, deleting, and updating records ,Grouping, Hierarchy relations, Filtering, Sorting and Paging these methods are recommended. Please try and let me know if any concern.

Thanks,
Princy
0
Sajjad A.
Top achievements
Rank 1
answered on 13 Mar 2014, 11:25 AM
i tried adding datasource with NeedDataSource event, but the result is still same :(
0
Princy
Top achievements
Rank 2
answered on 14 Mar 2014, 03:58 AM
Hi Sajjad,

I see that you are doing automatic CRUD operation and binding the Grid from code behind. When having Automatic CRUD operation you should use Declarative DataSource, and if you are doing your Insert/Update/Delete operation through Manual CRUD you can use NeedDataSource event. Please take a look at this demo to know the difference in Manual CRUD Operations and Automatic Operations.
Please provide your code behind as well if this didn't help.

Thanks,
Princy
0
Eric Downey
Top achievements
Rank 1
answered on 03 Jul 2014, 02:54 PM
Yeah, I'm getting the exact same issue.  Without the GridTemplateColumn all is well.  Add a very simple GridTemplateColumn and my grid goes blank except for the label in the GridTemplateColumn and the button columns.  Here's my grid.  It's super simple - not much to it.

<telerik:RadGrid ID="rgClassGrid" runat="server" AutoGenerateColumns="False" CellSpacing="0" DataSourceID="odsClassGrid" GridLines="None" Width="875px">
        <MasterTableView DataSourceID="odsClassGrid" DataKeyNames="Id" >
            <Columns>
                <telerik:GridButtonColumn UniqueName="editColumn" Text="Edit" HeaderStyle-Width="75px" />
                <telerik:GridHyperLinkColumn   HeaderStyle-Width="75px" Text="Sessions" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Teacher/ManageSessions.aspx?ClassId={0}" />
                
                <telerik:GridBoundColumn UniqueName="titleColumn" HeaderText="Title" DataField="Name" HeaderStyle-Width="350px" />
                <telerik:GridBoundColumn UniqueName="startDateColumn" HeaderText="Start Date" DataField="StartDate" HeaderStyle-Width="100px" />
                <telerik:GridBoundColumn UniqueName="endDateColumn" HeaderText="End Date" DataField="EndDate" HeaderStyle-Width="100px" />
                <telerik:GridTemplateColumn HeaderText="Draft" HeaderStyle-Width="100px">  
                    <ItemTemplate>  
                        <asp:Label ID="Label1" runat="server" Text='<%# Convert.ToBoolean(Eval("Draft")) ? "Yes" : "No" %>' />  
                    </ItemTemplate>  
                </telerik:GridTemplateColumn> 

                <telerik:GridButtonColumn UniqueName="deleteColumn" Text="Delete" HeaderStyle-Width="75px" />
                
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
0
Eyup
Telerik team
answered on 08 Jul 2014, 10:51 AM
Hi Eric,

I've created a sample RadGrid web site using the provided code snippet to test the described behavior. On my side the grid is loaded and displayed as expected. Please run the attached application and let me know about the result.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mohamed
Top achievements
Rank 1
answered on 01 Oct 2015, 09:45 AM

I had The Same Problem And I Solved It .. In my case The problem was That my Application I Used Telerik 2013 Pack And I updated my package to 2014 and the solution was made with 2013 pack The Solution is to remove  References of    Telerik.Web.UI   and Telerik.Web.UI.Skins   and re add the new references from The New Package from path 

C:\Program Files (x86)\Telerik\UI for ASP.NET AJAX Q2 2014\Bin45

Tags
Grid
Asked by
Sajjad A.
Top achievements
Rank 1
Answers by
Jeffrey
Top achievements
Rank 1
Sajjad A.
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Eric Downey
Top achievements
Rank 1
Eyup
Telerik team
Mohamed
Top achievements
Rank 1
Share this question
or