我有一个DataBound DetailsViewControl。用于显示一些问题和答案选项以及正确的答案
<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>
但是我想要隐藏用户的正确答案字段我试图让CorrectAnswer feild从Designer中看不见而且我成功但我的问题是当我尝试读取Invisible feild的值时
a.CorrectAnswer = DetailsView1.Rows[5].Cells[1].Text;
我将空字符串作为隐藏的详细信息视图字段中的值
任何人都可以建议任何方式使该字段不可见但保持值可以访问
后面的代码答案 0 :(得分:1)
将CssClass
设置为invisible
CssClass="invisible"
并创建不可见的css类:
.invisible {
display:none;
}