首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 100分未解决问题,继续提 [已结贴,结贴人:szoe5203]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • szoe5203
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 揭帖率:
    发表于:2008-08-08 17:32:57 楼主
    数据库的结构是这样的
    testitemid int 主键
    testid int 外键
    itemname nvarchar
    select1 nvarchar
    score1 int
    select2 nvarchar
    score2 int
    select3 nvarchar
    score3 int
    select4 nvarchar
    score4 int
    select5 nvarchar
    score5 int
    每个testid对应最少一个testitemid(对应的testitemid个数也不确定),每个testitemid最少对应了一个select1和score1,最多对应5对select和score(对应的select和score对数不一定)

    比如数据库的有如下的内容
    testid itemname select1 score1 select2 score2 select3 score3
    1      测试项1  是      1      不知道  2      不是    3
    1      测试项2  是      1      不知道  2      不是    3
    1      测试项3  是      1      不知道  2      不是    3
    2      测试项1  是      1      不知道  2      不是    3
    2      测试项2  是      1      不知道  2      不是    3
    2      测试项3  是      1      不是    2
    2      测试项4  是      1      不是    2
    我想要的效果是
    当我传到的参数是testid=1时,在这个页面显示testid=1的所有itemname以及其select和score
    效果如下
    测试项1
    单选按钮 是 1
    单选按钮 不知道 2
    单选按钮 不是 3

    测试项2
    单选按钮 是 1
    单选按钮 不知道 2
    单选按钮 不是 3

    测试项3
    单选按钮 是 1
    单选按钮 不知道 2
    单选按钮 不是 3

    当我传到的参数是testid=2时,在这个页面显示testid=2的所有itemname以及其select和score
    测试项1
    单选按钮 是 1
    单选按钮 不知道 2
    单选按钮 不是 3

    测试项2
    单选按钮 是 1
    单选按钮 不知道 2
    单选按钮 不是 3

    测试项3
    单选按钮 是 1
    单选按钮 不是 2

    测试项4
    单选按钮 是 1
    单选按钮 不是 2

    C#,代码分离模式
    新手,请写完整详细一点
    谢谢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    100  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 17:50:561楼 得分:0
    使用DataList或者Repeater,就是要对数据库的null值要做判断
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • try999
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 18:03:182楼 得分:0
    Repeater
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 18:09:553楼 得分:0
    1.html
    HTML code
    <a href="b.aspx?testid=1">xxx</a>



    2.aspx

    HTML code
    <asp:DataList ID="DataList1" runat="server" DataKeyField="testitemid" DataSourceID="SqlDataSource1"> <ItemTemplate> <asp:Label ID="itemnameLabel" runat="server" Text='<%# Eval("itemname") %>'></asp:Label><br /> <asp:RadioButton ID="RadioButton1" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select1") %>' ToolTip='<%# Eval("score1") %>' Visible='<%# Eval("select1") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton2" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select2") %>' ToolTip='<%# Eval("score2") %>' Visible='<%# Eval("select2") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton3" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select3") %>' ToolTip='<%# Eval("score3") %>' Visible='<%# Eval("select3") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton4" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select4") %>' ToolTip='<%# Eval("score4") %>' Visible='<%# Eval("select4") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton5" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select5") %>' ToolTip='<%# Eval("score5") %>' Visible='<%# Eval("select5") != System.DBNull.Value %>'/><br /> </ItemTemplate> </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.\sqlexpress;Initial Catalog=Demo;Integrated Security=True" ProviderName="System.Data.SqlClient" SelectCommand="select * from test where testid = @testid"> <SelectParameters> <asp:QueryStringParameter Name="testid" QueryStringField="testid" /> </SelectParameters> </asp:SqlDataSource>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • yuantaolzu
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 18:34:324楼 得分:0
    最近太忙没空写,但帮你顶
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • szoe5203
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 18:49:365楼 得分:0
    我按照楼上的代码
    修改了连接字符串
    ConnectionString="Data Source=local;Initial Catalog=gra_design;Integrated Security=True"
    但是却没有显示
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 18:57:076楼 得分:0
    楼主,你的由前一个页面跳转过来..

    <a href="b.aspx?testid=1">xxx </a>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • szoe5203
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 19:15:117楼 得分:0
    楼上说的我知道
    关键是这个页面的显示问题
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 19:18:118楼 得分:0
    我测试过可以出数据的
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 19:19:449楼 得分:0
    HTML code
    create table test ( testitemid int identity primary key, testid int, itemname nvarchar(1000), select1 nvarchar(1000) , score1 int , select2 nvarchar(1000) , score2 int , select3 nvarchar(1000), score3 int , select4 nvarchar(1000) , score4 int, select5 nvarchar(1000) , score5 int , ) insert into test(testid,itemname,select1,score1,select2,score2,select3,score3) values(1,'测试项1','是',1,'不知道',2,'不是',3) insert into test(testid,itemname,select1,score1,select2,score2,select3,score3) values(1,'测试项2','是',1,'不知道',2,'不是',3) insert into test(testid,itemname,select1,score1,select2,score2,select3,score3) values(1,'测试项3','是',1,'不知道',2,'不是',3) insert into test(testid,itemname,select1,score1,select2,score2,select3,score3) values(2,'测试项1','是',1,'不知道',2,'不是',3) insert into test(testid,itemname,select1,score1,select2,score2,select3,score3) values(2,'测试项2','是',1,'不知道',2,'不是',3) insert into test(testid,itemname,select1,score1,select2,score2) values(2,'测试项3','是',1,'不是',2) insert into test(testid,itemname,select1,score1,select2,score2) values(2,'测试项4','是',1,'不是',2)
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 19:20:1010楼 得分:0
    HTML code
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="B.aspx.cs" Inherits="B" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <asp:DataList ID="DataList1" runat="server" DataKeyField="testitemid" DataSourceID="SqlDataSource1"> <ItemTemplate> <asp:Label ID="itemnameLabel" runat="server" Text='<%# Eval("itemname") %>'></asp:Label><br /> <asp:RadioButton ID="RadioButton1" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select1") %>' ToolTip='<%# Eval("score1") %>' Visible='<%# Eval("select1") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton2" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select2") %>' ToolTip='<%# Eval("score2") %>' Visible='<%# Eval("select2") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton3" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select3") %>' ToolTip='<%# Eval("score3") %>' Visible='<%# Eval("select3") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton4" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select4") %>' ToolTip='<%# Eval("score4") %>' Visible='<%# Eval("select4") != System.DBNull.Value %>'/><br /> <asp:RadioButton ID="RadioButton5" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select5") %>' ToolTip='<%# Eval("score5") %>' Visible='<%# Eval("select5") != System.DBNull.Value %>'/><br /> </ItemTemplate> </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.\sqlexpress;Initial Catalog=Demo;Integrated Security=True" ProviderName="System.Data.SqlClient" SelectCommand="select * from test where testid = @testid"> <SelectParameters> <asp:QueryStringParameter Name="testid" QueryStringField="testid" /> </SelectParameters> </asp:SqlDataSource> </form> </body> </html>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • szoe5203
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 19:20:5211楼 得分:0
    怎么我打开页面完全是空白的呢
    还有这个页面是一样的问题
    http://topic.csdn.net/u/20080807/16/6d33abb6-feb2-449e-8c95-619e64e5d2aa.html
    解决了200分一并奉上
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 19:23:2612楼 得分:0
    你是跳转过来的么?

    连接的地方注意

    <a href="b.aspx?testid=1">xxx </a>

    等号前后千万不能有空格
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • amandag
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    • 2

      5

    发表于:2008-08-08 19:24:4913楼 得分:0
    如果还不行贴楼主的代码
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • szoe5203
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 19:25:1014楼 得分:0
    这里我知道
    我测试的时候是直接定义了testid=1的
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • shadowjl
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 19:31:0715楼 得分:0
    mark
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • szoe5203
    • 等级:
    • 可用分等级:
    • 总技术专家分:
    • 总技术专家分排名:
    发表于:2008-08-08 19:33:5816楼 得分:0
    C# code
    using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Text; using System.Xml; public partial class test : System.Web.UI.Page { int testid; string testtitle, statement, itemname; DataSet ds = new DataSet(); protected void Page_Load(object sender, EventArgs e) { //testid = System.Convert.ToInt32(Request.QueryString["testid"]); testid = 22; gettesttitle(); getstatement();