Click to See Complete Forum and Search --> : Gridview clears all columns not shown


ensingg
09-05-2006, 10:00 AM
I have a gridview that shows only some of the columns in the datasource. When I do an EDIT/UPDATE in the gridview the other columns that are not shown (example ADRES) are blank.
What am I doing wrong? The update command contains the ADRES field.

(it's not only the adressfield, all other not shown columns are blank too, after an edit)

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan"
BorderWidth="1px" CellPadding="2" DataSourceID="SqlDataSource1" ForeColor="Black"
GridLines="None" DataKeyNames="Bestelnr" SelectedIndex="0" SelectedRowStyle-BackColor="#F0F0F0">
<FooterStyle BackColor="Tan" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="Bestelnr" HeaderText="Bestelnr" ReadOnly="True" SortExpression="Bestelnr" />
<asp:BoundField DataField="Besteldatum" HeaderText="Besteldatum" ReadOnly="True" SortExpression="Besteldatum" />
<asp:BoundField DataField="tracenummer" HeaderText="tracenummer" SortExpression="tracenummer" />
<asp:BoundField DataField="Achternaam" HeaderText="Achternaam" SortExpression="Achternaam" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="Bezorg_Naam" HeaderText="Bezorg_Naam" SortExpression="Bezorg_Naam" />
<asp:BoundField DataField="Bezorg_Woonplaats" HeaderText="Bezorg_Woonplaats" SortExpression="Bezorg_Woonplaats" />
<asp:BoundField DataField="totaal" HeaderText="totaal" SortExpression="totaal" />
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>

ensingg
09-06-2006, 12:45 PM
http://www.beansoftware.com/ASP.NET-Tutorials/GridView-Hidden-Column.aspx

Protected Sub GridView1_OnRowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If (e.Row.RowType = DataControlRowType.Header) Or (e.Row.RowType = DataControlRowType.DataRow) Then

Dim intTeller
For intTeller = 8 To (e.Row.Cells.Count - 1)
e.Row.Cells(intTeller).Visible = False
Next


End If
End Sub