GridView column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HI ALL:

I have a gridview and display 4 columns , one of the column is ID , which i
don't wanna to visible. The problem i got is that the update , insert and
delet function doesn't work if i set the ID column visiable to false.

How can i handle this case?

Cheers

Nick
 
Hi Nick

Easy solution:
Include Visible="False" in te column of the ID
See below:
Guy
===========================
<asp:GridView ID="gridBlackListStrings" runat="server" AllowSorting="True"
AutoGenerateColumns="False" AutoGenerateSelectButton="True"
DataKeyNames="BlacklistStringID" DataSourceID="sqlBlackListStrings">

<Columns>

<asp:BoundField DataField="BlacklistStringID" visible="false"
HeaderText="BlacklistStringID" InsertVisible="False" ReadOnly="True"
SortExpression="BlacklistStringID" />

<asp:BoundField DataField="BlackListString" HeaderText="BlackListString"
SortExpression="BlackListString" />

</Columns>

</asp:GridView>

===========================
 
Nick,

Columns and any other server controls with Visible=false don't get rendered
to client. As a result, they don't come back on postbacks and don't keep
their values. If you are interested in a hidden column value either on
client side or in postbacks, you should keep Visible=true and hide the
column with css rule display:none.
 
Back
Top