From: Finn Stampe Mikkelsen on

I have below GridView, which i in codebehind page databind with a dynamicly
created datatable.

This all works fine, but after the databind i still only have a column count
of 1 although the datatable adds another 4 columns to the gridview. This
represents a problem, since i would like to have the last column properties
change on the fly and i cannot access the properties of any column besides
the on definded below. None of the databound columns created by the DataBind
method can be accessed..

How can i access these columns??


<asp:GridView ID="UdlaanGrd" runat="server" CellPadding="4"
GridLines="None" onrowcommand="UdlaanGrd_RowCommand" >

<asp:ButtonField ButtonType="Button"
HeaderText="Fjern Vare" Text="Fjern"
CommandName="Fjern" >
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="White" />

<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />

Der er 10 slags mennesker - Dem som forst�r bin�r og dem som ikke g�r.
There are 10 kinds of people. Those who understand binary and those who
Es gibt 10 Arten von Menschen. Die, die Bin�r verstehen, bzw. die, die es
nicht tuhen.

From: Rajeev Gopal on
Can you try this:


You could place this in Prerender to get the count.
From: Finn Stampe Mikkelsen on
"Rajeev Gopal" <rajeevg.nair(a)> skrev i meddelelsen
> Can you try this:
> sampleGridView.Rows(0).Cells.Count?
> You could place this in Prerender to get the count.

I know the count of cells and it's correct and as expected in regard to the
SqlDataSource.Select command... What i need is a way to dynamicly determin
if i wan't to show a specific column of the data bound from the

If for some reason i dont want to see the 3rd column, i want to do a
..visible = false; to the property of that column. I cannot do that, but i
can do it the individuel rows 3rd cell (Cells[3]). This leaves the header
row visible and indicates to the user that data is invisible.

Whar i don't understand is, why the databound gridview, after the dataBind,
cannot return a correct column.count but the individual rows of the same
gridview can... I don't see the reason for this and think there must be some
hack to do it...