From: Finn Stampe Mikkelsen on
Hi

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??

/Finn

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

<Columns>
<asp:ButtonField ButtonType="Button"
HeaderText="Fjern Vare" Text="Fjern"
CommandName="Fjern" >
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:ButtonField>
</Columns>
<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" />
</asp:GridView>

--
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
don't.
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:

sampleGridView.Rows(0).Cells.Count?

You could place this in Prerender to get the count.
From: Finn Stampe Mikkelsen on
"Rajeev Gopal" <rajeevg.nair(a)gmail.com> skrev i meddelelsen
news:1ca66f73-9a74-435c-a2c9-5fb17926f4a2(a)u11g2000vbd.googlegroups.com...
> 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
SqlDataSource.

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...

/Finn