473,385 Members | 1,464 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,385 software developers and data experts.

ASP.NET 2.0 Gridview Column Ordering

Hi,

In ASP.NET 2.0 I have a class called Cols (shown below) which keeps a record
of the different columns in my gridview. I need this because sometimes I
need to show/hide columns and need to know their position. One problem with
this is that whenever we add a column to the gridview i need to add it to
this Cols class and if it's at the beginning then every column after it has
to be renumbered.
Is there a way to somehow have the Cols fields auto number themselves, or is
there an overall better way to keep track of your columns so it's easy to
locate them for showing/hiding?

Public Class Cols
Public Shared Office As Int16 = 1
Public Shared TruckerName As Int16 = 2
Public Shared TruckerCode As Int16 = 3
Public Shared TotalContainers As Int16 = 4
Public Shared DOsNotReceived As Int16 = 5
Public Shared DOsNotReceived__Pct As Int16 = 6
Public Shared DOsPastDue As Int16 = 7
Public Shared DOsPastDue__Pct As Int16 = 8
Public Shared ContainersNotPickedUp As Int16 = 9
Public Shared ContainersNotPickedUp__Pct As Int16 = 10
Public Shared ContainersNotDelivered As Int16 = 11
Public Shared ContainersNotDelivered__Pct As Int16 = 12
Public Shared EmptiesNotPU As Int16 = 13
Public Shared EmptiesNotPU__Pct As Int16 = 14
Public Shared EmptiesNotReturned As Int16 = 15
Public Shared EmptiesNotReturned__Pct As Int16 = 16
Public Shared TotalMean As Int16 = 17
End Class

Thanks,
John

Jun 27 '08 #1
3 865
"John Walker" <Jo********@discussions.microsoft.comwrote in message
news:9A**********************************@microsof t.com...
Is there a way to somehow have the Cols fields auto number themselves, or
is
there an overall better way to keep track of your columns so it's easy to
locate them for showing/hiding?
I have to say I'm scratching my head as to why you need a separate class
just for this...?

Why not just use a generic e.g. Dictionary<string, intor Dictionary<int,
string>...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
Mark,
Would you please give me an example of how to use Dictionary? I've never
used that before.
Thanks

"Mark Rae [MVP]" wrote:
"John Walker" <Jo********@discussions.microsoft.comwrote in message
news:9A**********************************@microsof t.com...
Is there a way to somehow have the Cols fields auto number themselves, or
is
there an overall better way to keep track of your columns so it's easy to
locate them for showing/hiding?

I have to say I'm scratching my head as to why you need a separate class
just for this...?

Why not just use a generic e.g. Dictionary<string, intor Dictionary<int,
string>...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #3
"John Walker" <Jo********@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...

[top-posting corrected]
>>Is there a way to somehow have the Cols fields auto number themselves,
or
is there an overall better way to keep track of your columns so it's
easy to
locate them for showing/hiding?

I have to say I'm scratching my head as to why you need a separate class
just for this...?

Why not just use a generic e.g. Dictionary<string, intor
Dictionary<int,
string>...?

Would you please give me an example of how to use Dictionary? I've never
used that before.
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4

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

Similar topics

0
by: Per Rollvang | last post by:
Hi All! I use a special ListViewItemComparer-class to sort items in a listview for any column, and I have also allowed column-reordering. So far so good, but if I click the columnheader of any...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
0
by: hammad.awan_nospam | last post by:
Hello, I am using ASP.NET 2.0. What I have done is nested a gridview inside another column of a gridview using a template data field column declaritively in my web form. Inside this child...
1
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes...
11
by: surya | last post by:
hello sir, i have a table emp ,it has three fields one is empno int ,second is ename varchar(20). and last is salary , emp empno ename salary ----------- ------------...
1
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
1
by: =?Utf-8?B?UGF0cmljayBG?= | last post by:
I have a gridview on the page that i want to dynamically populate with radiobuttons, so i went out on the net and found something that works perfectly, it created radionuttons and the postback with...
1
by: Jeff | last post by:
ASP.NET 2.0 I've got problems with the right column in my GridView. The GridView consist of 2 columns, the problem column is the column on the right side. The problem is that it looks like...
5
by: NKaufman | last post by:
<asp:GridView ID="Basic" runat="server" DataKeyNames="QuestionID,isHeading" AutoGenerateColumns="false" AllowPaging="true" PageSize="100"> <Columns> <asp:BoundField Visible="false"...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.