Problem using GridView1.Columns.Insert(2, nameColumn);

C

Chicagoboy27

It seems when I use GridView1.Columns.Insert(2, nameColumn); to
dynamically insert a column into a grid I loose all items that are
bound using

<asp:TemplateField HeaderText="E-Mail" >
<ItemTemplate>
<a href='mailto:<%# Eval("email")%>'
target="new"><asp:Label ID="email" runat="server" Text='<%#
Bind("email")%>'></asp:Label></a>

</ItemTemplate>
<ItemStyle Wrap="true" />
</asp:TemplateField>

Here is my scenerio I have an if statement that checks a criteria. if
it matches I want that column in the table.....

I can use the GridView1.Columns.Add(nameColumn); and all the fields
work fine but the added field is in not in the position that I
want......

any suggestions?
 
C

Chicagoboy27

I think I may have found something that works.... I have eliminated the
use of the templatefield and have made it a bounddield

this seems to work with the GridView1.Columns.Insert(2, nameColumn);

<asp:BoundField DataField="email" HeaderText="E-mail"
SortExpression="email" DataFormatString="<a
href=&quot;mailto:{0}&quot;&gt;{0}</a>" />
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top