Duplicate TemplateField in a custom control deriving from GridView

S

Sunny

Hi,

I am having problem with a derived class from GridView in which I added
an empty image in the itemTemplate. Basically what I am trying to do is
adding an image column with an arrow instead of a select button. It
built fine, but when I modified any of the attributes in teh designer
mode, it kept adding another column of the same one. I think the
problem is because I added the column in teh class constructor but I
tried adding in OnLoad, OnInit and OnPreRender. Nothing works. Can
anyone point me out here? I am attaching my code herewith.

public class ItsGridView : System.Web.UI.WebControls.GridView
{


public ItsGridView()
{
TemplateField tf = new TemplateField();
tf.ItemTemplate = new
GridViewImageTemplate(DataControlRowType.DataRow);
tf.HeaderText = string.Empty;
this.Columns.Insert(0, tf);
}
}

Thank you in advance,

Sunny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top