473,382 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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?

Oct 4 '06 #1
1 3387
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>" />

Chicagoboy27 wrote:
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?
Oct 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Scott Meddows | last post by:
I have a datagrid control that I've inherited from the base datagrid control (Source below). I am applying a datatable style onto the datatable that I assign as my datasource. All of my column...
1
by: Chicagoboy27 | last post by:
I have dynamically bound a field to a gridview using the follwoing code: BoundField nameColumn = new BoundField(); nameColumn.DataField = "territory"; nameColumn.HeaderText = "Terr Num";...
3
by: rn5a | last post by:
A SqlDataReader is populated with the records from a SQL Server 2005 DB table. The records retrieved depends upon 2 conditions (the conditions depend on what a user selects in an ASPX page). If...
0
by: sathyan8294 | last post by:
i am using dotnet 2003.i am doing my project in vb.net windows application.i have two form in my project.first form is datagrid .In second form label and textboxes are avilable to save the entering...
1
by: sathyan8294 | last post by:
i am using dotnet 2003.i am doing my project in vb.net windows application.i have two form in my project.first form is datagrid .In second form label,textboxes and combobox are avilable to save the...
5
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi, I wonder if anyone can help? I've got a web form (intranet), .net version 1.1. I've got a sub that populates a datatable in a dataset, dependent on a dropdown field selection. This works...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.