Shaitan00
February 12th, 2005, 08:07 PM
Given a Datagrid [dgStatus] and an associated datasource [dataset ds] in C# [ASP.NEt]
dgStatus.DataSource = ds;
dgStatus.DataBind();
The Datasource [ds] contains 5 columns (Name, Pos, X, Y, Z) however I only want to display the first two columns in the Datagrid.
Therefore I did the following in my .aspx page:
<asp:datagrid id="dgStatus" runat="server">
<columns>
<asp:BoundColumn HeaderText="Device Name" DataField="Name"></asp:BoundColumn>
<asp:BoundColumn HeaderText="Device Position" DataField="Pos"></asp:BoundColumn>
</columns>
</asp:datagrid><br>
However this does not deliver the desirable results.
Intead of 2 columns [with headers "Device Name" and "Device Position"] I get 7 columns [with headers "Device Name" and "Device Position" (correctly bound) and the 5 from the original Datasource [Name, Pos, X, Y, Z].
So all I want to see is the 2 databound columns with the appropriate headers and not the additional 5 columns. Any clues?
dgStatus.DataSource = ds;
dgStatus.DataBind();
The Datasource [ds] contains 5 columns (Name, Pos, X, Y, Z) however I only want to display the first two columns in the Datagrid.
Therefore I did the following in my .aspx page:
<asp:datagrid id="dgStatus" runat="server">
<columns>
<asp:BoundColumn HeaderText="Device Name" DataField="Name"></asp:BoundColumn>
<asp:BoundColumn HeaderText="Device Position" DataField="Pos"></asp:BoundColumn>
</columns>
</asp:datagrid><br>
However this does not deliver the desirable results.
Intead of 2 columns [with headers "Device Name" and "Device Position"] I get 7 columns [with headers "Device Name" and "Device Position" (correctly bound) and the 5 from the original Datasource [Name, Pos, X, Y, Z].
So all I want to see is the 2 databound columns with the appropriate headers and not the additional 5 columns. Any clues?