473,508 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to set COLUMN ID in an html table genereted through datagrid in asp.net

Hi all,
I'm kinda new to asp.net. I'm using a datagrid which shows data from
a table...simple enough. Now I have a javascript (which I found on
the web) which allows me to hide/show (or expand/collapse) column on
the html table on client side. This functionality is great since it
allows users to decide which column to see while ignoring a large
number of column they find irrelevant.
The problem is that this script wants each column to have its own id
(so first column in each row would have the same id, second column
from each row would have its own...etc.). For the life of me, I can't
figure out how to do this. This also brings up the issue of finer
control over the generated table when using the datagrid. Do I have
to resort to subclassing the datagrid control (even then I'm not sure
how I would access the internal table generating code)? Is there some
sort of 'onBind' logic I have to use which keeps track of every cell
using a counter then manually assigns an id (wouldn't that be
slow...not that I know how to do that either). Any ideas?
Thanks.
Shahbaz Chaudhary
Nov 17 '05 #1
2 2178
Ram
In Datagrid ItemDatabound event you can write like this

Dim tc As TableCell = e.Item.Cells(0)
tc.ID = "AAAAAAAA"

It will create and id for the table cell like the following.

id="DataGrid2__ctl3_AAAAAAAA"

DataGrid2__ctl3_ is rendered by ASP.NET to find the control during
postback.

If you can publish what you are trying to do on the client side, I can
help you more. Send mail directly to me.

Hope this can help.
Ram

ch******@umich.edu (shahbaz) wrote in message news:<1c**************************@posting.google. com>...
Hi all,
I'm kinda new to asp.net. I'm using a datagrid which shows data from
a table...simple enough. Now I have a javascript (which I found on
the web) which allows me to hide/show (or expand/collapse) column on
the html table on client side. This functionality is great since it
allows users to decide which column to see while ignoring a large
number of column they find irrelevant.
The problem is that this script wants each column to have its own id
(so first column in each row would have the same id, second column
from each row would have its own...etc.). For the life of me, I can't
figure out how to do this. This also brings up the issue of finer
control over the generated table when using the datagrid. Do I have
to resort to subclassing the datagrid control (even then I'm not sure
how I would access the internal table generating code)? Is there some
sort of 'onBind' logic I have to use which keeps track of every cell
using a counter then manually assigns an id (wouldn't that be
slow...not that I know how to do that either). Any ideas?
Thanks.
Shahbaz Chaudhary

Nov 17 '05 #2
Ram
Instead of
tc.ID = "AAAAAAAA"
use
tc.Attributes("ID") = "HeyRam"

ra**********@yahoo.com (Ram) wrote in message news:<fe**************************@posting.google. com>...
In Datagrid ItemDatabound event you can write like this

Dim tc As TableCell = e.Item.Cells(0)
tc.ID = "AAAAAAAA"

It will create and id for the table cell like the following.

id="DataGrid2__ctl3_AAAAAAAA"

DataGrid2__ctl3_ is rendered by ASP.NET to find the control during
postback.

If you can publish what you are trying to do on the client side, I can
help you more. Send mail directly to me.

Hope this can help.
Ram

ch******@umich.edu (shahbaz) wrote in message news:<1c**************************@posting.google. com>...
Hi all,
I'm kinda new to asp.net. I'm using a datagrid which shows data from
a table...simple enough. Now I have a javascript (which I found on
the web) which allows me to hide/show (or expand/collapse) column on
the html table on client side. This functionality is great since it
allows users to decide which column to see while ignoring a large
number of column they find irrelevant.
The problem is that this script wants each column to have its own id
(so first column in each row would have the same id, second column
from each row would have its own...etc.). For the life of me, I can't
figure out how to do this. This also brings up the issue of finer
control over the generated table when using the datagrid. Do I have
to resort to subclassing the datagrid control (even then I'm not sure
how I would access the internal table generating code)? Is there some
sort of 'onBind' logic I have to use which keeps track of every cell
using a counter then manually assigns an id (wouldn't that be
slow...not that I know how to do that either). Any ideas?
Thanks.
Shahbaz Chaudhary

Nov 17 '05 #3

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

Similar topics

6
8394
by: Das | last post by:
Hi everyone, I'm using datagrid control to display the data. I want to hide column to be displayed into the data grid. I'm using the code as given below: Method given below is used to bind the...
0
2631
by: Amber | last post by:
There are times when you will need to highlight or otherwise modify the contents of a particular DataGrid row-column value based upon the value in the column. In this example we will select the...
17
7413
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5...
10
4927
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
5
3689
by: Rich | last post by:
I have a datagrid that uses a dataview object for its datasource. The dataview contains a unique row identifier column. I don't want to display this column in the datagrid. I need the unique row...
9
6090
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
2
10377
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
2
1360
by: mark4asp | last post by:
This page is currently using a Repeater control to create a table with 6 columns. The first column has 2 ImageButton controls and a common header. How can I do this with a DataGrid ? I need...
5
1938
by: vpravin | last post by:
Hi guys...i am a super noob with html and aspx.. i didnt start this project but i am modifying it... q: how do i change the width of a column: Thats the table which is within a text box ...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.