<asp:Repeater ID="rpQu" runat="server" OnItemDataBound="rpQu_ItemDataBound">
<ItemTemplate>
<table border=0 cellpadding=5 cellspacing=0 width=100% runat=server id="tblOB">
<tr><td height=22 bgcolor=Gainsboro><b><font color=DarkOrange><%# (bool)Eval("OB") == true?"客观题部分:":"主观题部分:"%></font></b></td></tr>
<tr><td height=10></td></tr>
</table>
<table border=0 cellpadding=2 cellspacing=0 width=100%>
<tr>
<td>
<%# Container.ItemIndex + 1 %>、<%# Eval("question") %>
<%# (bool)Eval("RadioCheckBox") == true ? "(多选题)":"(单选题)" %>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="dlsel" runat="server" CellPadding=2 CellSpacing=0 RepeatColumns=2 RepeatDirection=Horizontal OnItemDataBound="dlsel_ItemDataBound">
<ItemTemplate>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td><asp:CheckBox ID="chksel" runat=server Visible=false /><asp:RadioButton ID="rdsel" runat=server Visible=false /> </td>
<td id="td1" runat=server><%# Eval("Option")%>.<%# Eval("Showtxt")%> <%# (string)Eval("Memo") == "" ? "":"("+Eval("Memo")+")" %></td>
<td id="td2" runat=server><asp:TextBox ID="txtother" runat=server Width=120 CssClass="textbox_2d3"></asp:TextBox></td>
</tr>
</table>
</ItemTemplate>
<SeparatorStyle Width=30 />
<SeparatorTemplate></SeparatorTemplate>
</asp:DataList>
</td>
</tr>
<tr><td height=5></td></tr>
<tr><td height=1 bgcolor=Gainsboro></td></tr>
<tr><td height=15></td></tr>
</table>
</ItemTemplate>
</asp:Repeater> =================================================================================================protected void rpQu_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
HtmlTable tbl;
DataList dlq;
DataRowView drv;
CREATIVE_OPTION op = new CREATIVE_OPTION();
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
drv = (DataRowView)e.Item.DataItem;
tbl = (HtmlTable)e.Item.FindControl("tblOB");
if (boolOB == bool.Parse(drv["OB"].ToString()))
{
tbl.Visible = true;
if (boolOB) { boolOB = false; } else { boolOB = true; }
}
else
{
tbl.Visible = false;
}
dlq = (DataList)e.Item.FindControl("dlsel");
op.QuestionRowId = int.Parse(drv["quRowid"].ToString());
dlq.DataSource = op.Select();
dlq.DataBind();
}
} protected void dlsel_ItemDataBound(object sender, DataListItemEventArgs e)
{
HtmlTableCell tdsel, tdfill;
CheckBox chksel;
RadioButton rdsel;
DataRowView drv;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
=========》就是在这儿怎么取Repeater值?然后再确定显示单先框还是多选,谢谢! tdsel = (HtmlTableCell)e.Item.FindControl("td1");
tdfill = (HtmlTableCell)e.Item.FindControl("td2");
drv = (DataRowView)e.Item.DataItem;
if (bool.Parse(drv["isfillin"].ToString()))
{
tdsel.Visible = false;
tdfill.Visible = true;
}
else
{
tdsel.Visible = true;
tdfill.Visible = false;
}
}
}
<ItemTemplate>
<table border=0 cellpadding=5 cellspacing=0 width=100% runat=server id="tblOB">
<tr><td height=22 bgcolor=Gainsboro><b><font color=DarkOrange><%# (bool)Eval("OB") == true?"客观题部分:":"主观题部分:"%></font></b></td></tr>
<tr><td height=10></td></tr>
</table>
<table border=0 cellpadding=2 cellspacing=0 width=100%>
<tr>
<td>
<%# Container.ItemIndex + 1 %>、<%# Eval("question") %>
<%# (bool)Eval("RadioCheckBox") == true ? "(多选题)":"(单选题)" %>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="dlsel" runat="server" CellPadding=2 CellSpacing=0 RepeatColumns=2 RepeatDirection=Horizontal OnItemDataBound="dlsel_ItemDataBound">
<ItemTemplate>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td><asp:CheckBox ID="chksel" runat=server Visible=false /><asp:RadioButton ID="rdsel" runat=server Visible=false /> </td>
<td id="td1" runat=server><%# Eval("Option")%>.<%# Eval("Showtxt")%> <%# (string)Eval("Memo") == "" ? "":"("+Eval("Memo")+")" %></td>
<td id="td2" runat=server><asp:TextBox ID="txtother" runat=server Width=120 CssClass="textbox_2d3"></asp:TextBox></td>
</tr>
</table>
</ItemTemplate>
<SeparatorStyle Width=30 />
<SeparatorTemplate></SeparatorTemplate>
</asp:DataList>
</td>
</tr>
<tr><td height=5></td></tr>
<tr><td height=1 bgcolor=Gainsboro></td></tr>
<tr><td height=15></td></tr>
</table>
</ItemTemplate>
</asp:Repeater> =================================================================================================protected void rpQu_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
HtmlTable tbl;
DataList dlq;
DataRowView drv;
CREATIVE_OPTION op = new CREATIVE_OPTION();
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
drv = (DataRowView)e.Item.DataItem;
tbl = (HtmlTable)e.Item.FindControl("tblOB");
if (boolOB == bool.Parse(drv["OB"].ToString()))
{
tbl.Visible = true;
if (boolOB) { boolOB = false; } else { boolOB = true; }
}
else
{
tbl.Visible = false;
}
dlq = (DataList)e.Item.FindControl("dlsel");
op.QuestionRowId = int.Parse(drv["quRowid"].ToString());
dlq.DataSource = op.Select();
dlq.DataBind();
}
} protected void dlsel_ItemDataBound(object sender, DataListItemEventArgs e)
{
HtmlTableCell tdsel, tdfill;
CheckBox chksel;
RadioButton rdsel;
DataRowView drv;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
=========》就是在这儿怎么取Repeater值?然后再确定显示单先框还是多选,谢谢! tdsel = (HtmlTableCell)e.Item.FindControl("td1");
tdfill = (HtmlTableCell)e.Item.FindControl("td2");
drv = (DataRowView)e.Item.DataItem;
if (bool.Parse(drv["isfillin"].ToString()))
{
tdsel.Visible = false;
tdfill.Visible = true;
}
else
{
tdsel.Visible = true;
tdfill.Visible = false;
}
}
}
e.Item.DataItem
//example TypeInfo type = (TypeInfo)e.Item.DataItem;
dlq.DataSource = op.Select();
你反向查找一下drv["quRowid"] 它应该是唯一的吧~
你不是根据它来动态绑顶DataList的么, 在DataList的ItemDataBound中找到当前drv["quRowid"]
然后根据当前drv["quRowid"] 上Repeater 的数据源中查找想要的不赞同你的绑顶方式~
也可以通过 label 等来传值
{
HtmlTableCell tdsel, tdfill;
CheckBox chksel;
RadioButton rdsel; RepeaterItem rpitem;
DataRowView drv,drvrp;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
rpitem = (RepeaterItem)(((DataList)sender).NamingContainer);
drvrp = (DataRowView)rpitem.DataItem; chksel = (CheckBox)e.Item.FindControl("chksel");
rdsel = (RadioButton)e.Item.FindControl("rdsel");
if (bool.Parse(drvrp["radiocheckbox"].ToString())) ====> 这个drvrp是repeater已绑定的值
{
chksel.Visible = true;
}
else
rdsel.Visible = true; tdsel = (HtmlTableCell)e.Item.FindControl("td1");
tdfill = (HtmlTableCell)e.Item.FindControl("td2");
drv = (DataRowView)e.Item.DataItem;
if (bool.Parse(drv["isfillin"].ToString()))
{
tdsel.Visible = false;
tdfill.Visible = true;
}
else
{
tdsel.Visible = true;
tdfill.Visible = false;
}
}
}
=========> to Sandy945 : [quRowid]字段是唯一的,但repeater已经绑定了需要值,没必要再根据[quRowid]
查询数据库得到所要的值,不过谢谢啦。