救命啊:如何在一个Repeater中绑定一个问题跟多个答案,但答案有单选跟多选。。。。。。。。。。。。。。。

crazy123 2003-09-04 08:56:18
如何在一个Repeater中绑定一个问题跟多个答案,但答案有单选跟多选的情况。。。。。。。。。。。。。。。
怎么弄啊???
...全文
27 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hq1305018 2003-09-06
  • 打赏
  • 举报
回复
我做了一个自定义控制,tm.ascx这是全部代码。
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Web" %>
<%@ Import Namespace = "System.Web.UI" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<%@ Import Namespace = "System.Configuration"%>
<Script Language="C#" Runat="Server">
public string backcolor="blue";
public int das;
public int DxOrDx;
public string tempTmTxt;
public ListItem[] tempListItem=new ListItem[1];
void Page_Load(Object sender ,EventArgs e){
if(!IsPostBack)
{
if(DxOrDx==1)//单选或多选标记
{
TmDa1.Visible=true;
TmDa1.Enabled=true;
TmDa.Visible=false;
TmDa.Enabled=false;
for(int i=0;i<tempListItem.Length;i++)
{
TmDa1.Items.Add(tempListItem[i]);
}
}
else
{
TmDa.Visible=true;
TmDa.Enabled=true;
TmDa1.Visible=false;
TmDa1.Enabled=false;
for(int i=0;i<tempListItem.Length;i++)
{
TmDa.Items.Add(tempListItem[i]);
}

}
TmTxt.Text=tempTmTxt;
TmDa.DataBind();
TmDa1.DataBind();
}
}
public string getDa()
{
if(DxOrDx==1)
{
return Request.Form["TmDa1"];
}
else
{
return Request.Form["TmDa"];
}
}
</Script>
<table width="100%" border="0" bgcolor="<%=backcolor%>">
<tr>
<td><asp:label ID="TmTxt" runat="server"></asp:label></td>
</tr>
<tr>
<td><asp:checkboxlist ID="TmDa" RepeatDirection="Horizontal" Visible="false" Enabled="false" runat="server" textalignment="right"></asp:checkboxlist><asp:radiobuttonlist ID="TmDa1" RepeatDirection="Horizontal" runat="server" Visible="false" Enabled="false" textalignment="right"></asp:radiobuttonlist></td>
</tr>
</table>


以下是调用,也就是在页面里加上这个控件的引用,一道题引用一次,共六道题。

<%@ Page CodeBehind="zxdt1.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="game.zxdt.zxdt1" %>

<table width="100%" border="0" align="center" cellpadding="8">
<tr>
<td class="index"> <uc1:tm id="Tm1" runat="server"></uc1:tm></td>
</tr>
<tr>
<td class="index"> <uc1:tm id="Tm2" runat="server"></uc1:tm></td>
</tr>
<tr>
<td class="index"> <uc1:tm id="Tm3" runat="server"></uc1:tm></td>
</tr>
<tr>
<td class="index"> <uc1:tm id="Tm4" runat="server"></uc1:tm></td>
</tr>
<tr>
<td class="index"> <uc1:tm id="Tm5" runat="server"></uc1:tm></td>
</tr>
<tr>
<td class="index"> <uc1:tm id="Tm6" runat="server"></uc1:tm></td>
</tr>
</table>
不懂再发消息给我。

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧