Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
Hi all,
i am trying to add one ASPXGridView Column using DevExpress in server side of vb.net .
the column i have added successfully but i cannot add DataItemTemplate.
if am trying to add below code then i am getting below error,
So please drop me any solution.
Error:

Unable to cast object of type 'System.String' to type 'System.Web.UI.ITemplate'

My code is :

     colText = New DevExpress.Web.ASPxGridView.GridViewDataTextColumn
                colText.FieldName = "Image"
                colText.Caption = "Image"
                colText.VisibleIndex = "16"
                colText.DataItemTemplate = "<a href='javascript:void(0);' onclick='OnMoreInfoClick(this, '<%# Container.KeyValue %>')'>ShowImage</a>"  // here am getting above error
                colText.CellStyle.HorizontalAlign = HorizontalAlign.Right
                colText.CellStyle.Border.BorderColor = Drawing.Color.DarkBlue
                colText.CellStyle.Border.BorderStyle = BorderStyle.Double
                colText.EditFormCaptionStyle.HorizontalAlign = HorizontalAlign.Right
                colText.CellStyle.VerticalAlign = VerticalAlign.Middle
                colText.CellStyle.HorizontalAlign = HorizontalAlign.Right

                If Page.IsPostBack = False Then
                    Grid.Columns.Add(colText)
                End If




thanks in advance


What I have tried:

cannot add ASPXGridView Column using DevExpress in server side of vb.net
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900