大家帮忙看一下,我的填空题用datalist绑定的。
现在是从数据库中查询出填空题的问题为:新中国______时候成立的?
怎么样将_____改为文本框形式显示,并可能编辑。
protected void dgtiankong_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (chkTiankong.Checked)
{
HiddenField ht = (HiddenField)e.Item.FindControl("hidtiankong");
Label lbl = (Label)e.Item.FindControl("lblnames");
TextBox ts = (TextBox)e.Item.FindControl("TextBox1"); if ((ht != null) && (lbl != null))
{
if (ht.Value.ToString().Contains("T"))
{
lbl.Visible = true;
}
}
}
}
现在是从数据库中查询出填空题的问题为:新中国______时候成立的?
怎么样将_____改为文本框形式显示,并可能编辑。
protected void dgtiankong_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (chkTiankong.Checked)
{
HiddenField ht = (HiddenField)e.Item.FindControl("hidtiankong");
Label lbl = (Label)e.Item.FindControl("lblnames");
TextBox ts = (TextBox)e.Item.FindControl("TextBox1"); if ((ht != null) && (lbl != null))
{
if (ht.Value.ToString().Contains("T"))
{
lbl.Visible = true;
}
}
}
}
<head runat="server">
<title>无标题页</title>
<style type="text/css">
#TextBox1{
border-top-width:0px;
border-left-width:0px;
border-right-width:0px;
border-bottom-width:1px;
border-bottom-color:Black;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server">aaaaaaaaa</asp:TextBox>
</div>
</form>
</body>
</html>
<asp:DataList ID="dgtiankong" runat="server" GridLines="None" autoGenerateColumns="false"
HorizontalAlign="left" Width="100%" OnItemDataBound="dgtiankong_ItemDataBound">
<HeaderTemplate>
<asp:Label ID="lbltiankong" runat="server" Text="二、填空题"></asp:Label></HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblnames" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"subjectName") %>'></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Visible="false" Text='' TextMode="MultiLine" BorderStyle="None"></asp:TextBox>
<asp:HiddenField ID="hidtiankong" runat="server" Value='<%# DataBinder.Eval(Container.DataItem,"subjecNO") %>' />
<br />
</ItemTemplate>
</asp:DataList></div> 这个是我的前台。
<asp:TextBox id="TextBox1" runat="server" style="BORDER-BOTTOM:gray 1px solid" BorderStyle="None"></asp:TextBox> <%--ie7,ff测试通过--%><br />
<asp:TextBox id="TextBox2" runat="server" TextMode="multiLine" style="BORDER-BOTTOM: gray 1px solid" BorderStyle="None"></asp:TextBox> <%--ie7出现垂直滚动条,ff出现水平滚动条--%>
#TextBox1{
border-top-width:0px;
border-left-width:0px;
border-right-width:0px;
border-bottom-width:1px;
border-bottom-color:Black;
.input{
border-bottom:1px solid #007eff; /* 下划线 */
font-family:Arial, Helvetica, sans-serif;
color:#007eff;
background:transparent;
border-top:none;
border-left:none;
border-right:none;
}
</style> <asp:TextBox ID="TextBox1" runat="server" CssClass="input"></asp:TextBox>
#TextBox1{ border-top-width:1px;
border-left-width:1px;
border-right-width:1px;
border-bottom-width:1px;
border-color:Black;
<style type="text/css">
.textbox1
{
border-bottom:solid 1px #999999;
border-left:0px;
border-top:0px;
border-right:0px;
}
</style>
<div>
新中国<asp:TextBox ID="TextBox3" runat="server" CssClass="textbox1"></asp:TextBox>
时候成立的?
<br />
新中国<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>时候成立的?
</div>你看一下这两个效果