TelerikDeveloper.com

TelerikDeveloper.com

sgray128 10/14/2014 8:45:33 AM

ASP.NET GridTemplateColumn

This is an example of how to use the GridTemplateColumn                       


 Simple example. Note the formatting in the HyperLink NavigateURL:

 

<telerik:GridTemplateColumn
    <ItemTemplate
        <asp:Label ID="lblProjectName" runat="server" Text='<%# Bind("ProjectName") %>'></asp:Label><br />
        <asp:HyperLink ID="HyperLink1" runat="server"
            NavigateUrl='<%# string.format("ScanSand2.aspx?SOPNUMBE={0}&soptype={1}",Eval("sopnumbe"),Eval("soptype")) %>'
            Text='<%# Bind("sopnumbe") %>' /> 
    </ItemTemplate
    <EditItemTemplate
            <asp:TextBox ID="txtProjectName" runat="server" Text='<%# Bind("ProjectName") %>' /> 
    </EditItemTemplate>
  </telerik:GridTemplateColumn>

Example with a formatted date:

 

<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:Label ID="lblPostDate" Text='<%# String.Format("{0:MM/dd/yyyy}", DataBinder.Eval(Container.DataItem, "PostDate"))%>'  runat="server"></asp:Label><br />
        <asp:Label ID="lblUserName" Text='<%# Bind("UserName")%>' runat="server"></asp:Label>
    </ItemTemplate>
</telerik:GridTemplateColumn>