I have a GridView that get the data from the table in DB,
CREATE TABLE [dbo].[EDU_Room](
[Id] [tinyint] NOT NULL,
[Title] [nvarchar](50) NOT NULL,
[Floor] [tinyint] NULL,
[Capacity] [tinyint] NOT NULL,
[TypeId] [tinyint] NOT NULL)
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" Width="49%"
DataKeyNames="Id" CssClass="Hedear-center" HorizontalAlign="Center"
Font-Names="Tahoma" Font-Size="Smaller" Style="margin-right: 0px" DataSourceID="EditCourseDB">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id"
HeaderStyle-CssClass="Hedear-center" ReadOnly="True">
</asp:BoundField>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title"
HeaderStyle-CssClass="Hedear-center">
</asp:BoundField>
<asp:BoundField DataField="Floor" HeaderText="Floor" SortExpression="Floor"
HeaderStyle-CssClass="Hedear-center">
</asp:BoundField>
<asp:BoundField DataField="Capacity" HeaderText="Capacity" SortExpression="Capacity" HeaderStyle-CssClass="Hedear-center">
</asp:BoundField>
<asp:BoundField DataField="TypeId" HeaderText="TypeId" SortExpression="TypeId" HeaderStyle-CssClass="Hedear-center">
</asp:BoundField>
</Columns>
<EmptyDataTemplate>
<span class="auto-style14"><strong>هیچ واحد درسی تعریف نشده است</strong></span>
</EmptyDataTemplate>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
<asp:SqlDataSource ID="EditCourseDB" runat="server" ConnectionString="<%$ ConnectionStrings:KDUIS-v1ConnectionString %>"
SelectCommand="SELECT * FROM [EDU_Room]">
</asp:SqlDataSource>
now I don't want to show the Id field in GridView to the user. but I want to get the value of Id when I select each of row.
I can get the value of GridView white this code:
LblId.Text = row.Cells[0].Text;
and I set the:
Visible="false"
To hide the Id field. but when I set this property to false, I can't get the amount of Id field.
how can I do this?!