添加GridTemplateColumn会破坏RadGrid

时间:2014-07-20 08:01:13

标签: asp.net telerik radgrid

在GridTemplateColumn:

之前看起来像这样

enter image description here

添加GridTemplateColumn后

<telerik:GridTemplateColumn HeaderText="Name" HeaderStyle-Width="250" FilterControlWidth="250">                          
    <ItemTemplate>                                          
        <asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text='<%# Eval("Name") %>'></asp:HyperLink>
    </ItemTemplate>
</telerik:GridTemplateColumn>

enter image description here

尝试实施http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx?product=tooltip

我的RadGrid:

<telerik:RadGrid HorizontalAlign="Center" PageSize="50" ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" CellSpacing="0" AllowFilteringByColumn="false" Skin="Forest" DataSourceID="SqlDataSourceUyeAday" Height="400px" Width="100%" AutoGenerateColumns="False">
    <ClientSettings>
        <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
    </ClientSettings>
    <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSourceUyeAday">
        <Columns>
            <telerik:GridBoundColumn ItemStyle-CssClass="iceri" DataField="Id" ItemStyle-Width="50" HeaderStyle-Width="50" FilterControlWidth="50" FilterControlAltText="Filter Id column" HeaderText="Id" SortExpression="Id" UniqueName="AdayId">
                <ColumnValidationSettings>

                </ColumnValidationSettings>
            </telerik:GridBoundColumn>

            <telerik:GridTemplateColumn HeaderText="FirstName" SortExpression="FirstName" DataField="FirstName" UniqueName="FirstName" FilterControlAltText="Filter FirstName column" HeaderStyle-Width="250" FilterControlWidth="250">

                <ItemTemplate>

                    <asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text='<%# Eval("FirstName") %>'></asp:HyperLink>
                </ItemTemplate>
            </telerik:GridTemplateColumn>

            <telerik:GridDateTimeColumn DataField="Date" HeaderStyle-CssClass="iceriTarih" ItemStyle-CssClass="iceriTarih" FilterControlAltText="Filter Datecolumn" PickerType="DatePicker" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Date" SortExpression="Date" UniqueName="Date" DataType="System.DateTime" ItemStyle-Width="150" HeaderStyle-Width="150" FilterControlWidth="100">
                <ColumnValidationSettings>

                </ColumnValidationSettings>
            </telerik:GridDateTimeColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

可能是什么原因?

3 个答案:

答案 0 :(得分:11)

显然,这是必需的。

<appSettings>
   <add key="vs:EnableBrowserLink" value="false"/>
</appSettings>

从这里: Telerik control layout issues - Visual Studio 2013

答案 1 :(得分:0)

您的代码似乎很好。您正在使用&#39;姓名&#39;作为UniqueName和DataField。 &#39;名称&#39;是一个保留字,也许这就是你看到意外行为的原因。尝试使用其他名称,例如&#39; FirstName&#39;或者&#39;姓氏&#39;

答案 2 :(得分:0)

<telerik:GridTemplateColumn HeaderText="Status" HeaderStyle-Width="10%" ItemStyle-Width="10%"
    HeaderStyle-Font-Bold="true" UniqueName="Status" DataField='MstUserDefineCode.Code'>
                                <ItemTemplate>
                                    <asp:Label ID="LabelStatus" runat="server" Text='<%# Eval("ProjectStatus") %>'></asp:Label>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

您可以像上面代码一样使用模板列