Reputation: 736
I had a DataBound DetailsViewControl . for displaying some questions and answer option and the correct answer
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" DataSourceID="SqlDataSource1" GridLines="Vertical"
Height="50px" Width="477px" ForeColor="Black">
<AlternatingRowStyle BackColor="#CCCCCC" />
<EditRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="Question" HeaderText="Question"
SortExpression="Question" />
<asp:BoundField DataField="Answer 1" HeaderText="Answer 1"
SortExpression="Answer 1" />
<asp:BoundField DataField="Answer 2" HeaderText="Answer 2"
SortExpression="Answer 2" />
<asp:BoundField DataField="Answer 3" HeaderText="Answer 3"
SortExpression="Answer 3" />
<asp:BoundField DataField="Answer 4" HeaderText="Answer 4"
SortExpression="Answer 4" />
<asp:BoundField DataField="Correct Answer" HeaderText="Correct"
SortExpression="Correct Answer" >
<FooterStyle BorderColor="White" />
</asp:BoundField>
<asp:BoundField DataField="Id" SortExpression="Id" />
</Fields>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
</asp:DetailsView>
But I want to hide the correct answer field from the user I tried to make the CorrectAnswer feild invisible from Designer and I succeed but my issue is when I try to read the value of Invisible feild
a.CorrectAnswer = DetailsView1.Rows[5].Cells[1].Text;
I am getting Empty String as the value from the invisible Details View field
Can anyone suggest any way of making a the field invisible but keeping the value accessible to code behind
Upvotes: 0
Views: 41
Reputation: 76601
Set the CssClass
to invisible
CssClass="invisible"
and create the ivisible css class:
.invisible {
display:none;
}
Upvotes: 1