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

S

shahbaz

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
 
R

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
 

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

Top