| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 802 人关注过本帖
标题:数据绑定
只看楼主 加入收藏
馨馨
Rank: 1
等 级:新手上路
帖 子:136
专家分:0
注 册:2008-3-10
收藏
 问题点数:0 回复次数:7 
数据绑定
我做了个数据绑定,就是将表中的一个列和另一个页面绑定,但是这个列中的每一行点击连接时都跳转同样的界面同样的内容,怎么才能是每一行点击跳转到相同页面的不同内容呢,
搜索更多相关主题的帖子: 数据绑定 页面 界面 
2008-04-08 15:29
jalonlovesja
Rank: 5Rank: 5
来 自:湖南邵阳
等 级:职业侠客
帖 子:292
专家分:371
注 册:2008-2-19
收藏
得分:0 
看不懂你说的什么意思啊
  你说说你要做的是什么功能了 ?
2008-04-08 17:10
小乌龟
Rank: 2
等 级:新手上路
威 望:4
帖 子:1291
专家分:0
注 册:2007-9-28
收藏
得分:0 
if you develop by vs2003,please use frame,else if you develop by vs2005,plese use master page.
2008-04-08 17:27
hebingbing
Rank: 6Rank: 6
来 自:黄土高坡
等 级:贵宾
威 望:27
帖 子:3417
专家分:371
注 册:2007-10-22
收藏
得分:0 
给你的链接带参数,在另为页面接受参数,根据参数设置内容……
比如:herf=a.aspx?id=1……
在a.aspx中用request.querstring("id")……
然后根据id来设置你的a.aspx……
2008-04-08 17:32
馨馨
Rank: 1
等 级:新手上路
帖 子:136
专家分:0
注 册:2008-3-10
收藏
得分:0 
还是不明白  hebingbing 说的,具体点可以嘛,我不知道a .aspx是怎么接受传来的值,怎么实现动态效果呢
2008-04-08 22:08
hebingbing
Rank: 6Rank: 6
来 自:黄土高坡
等 级:贵宾
威 望:27
帖 子:3417
专家分:371
注 册:2007-10-22
收藏
得分:0 
比如说你的a页中的Gridview中的某一列绑定了链接
<asp:HyperLink      runat="server" Text='<%# DataBinder.Eval(container.DataItem,"name") %>‘  NavigateUrl='<%#"b.aspx?id="+DataBinder.Eval(Container.DataItem,"id")%>'>   

那么你在点击这个列HyperLink的时候就到了b页,你现在要在b也根据传过来的id显示页面对不对啊?
那么你就在b页这么写:
string nameid = Request.QueryString["id"];
接受了传过来的id,
然后假如说你要在b页显示这行的所有内容吧:
…………//一些连接数据库的代码,当然你要用到id的,where id=nameid……
接下来就是将数据显示到页面的问题了,应该没有问题了吧……
2008-04-08 22:34
馨馨
Rank: 1
等 级:新手上路
帖 子:136
专家分:0
注 册:2008-3-10
收藏
得分:0 
我是了一下,我的代码出错了,你帮帮我看看把 主要是一句话行 41:             SqlDataAdapter MyCommandnews = new SqlDataAdapter(sqlnews,sqlcon);//创建SqlDataAdapter对象,按照指定的查询语句获取结果
行 42:             DataSet ds = new DataSet ();//定义DataSet对象,将查询结果填充到这个对象上
行 43:             MyCommandnews.Fill(ds,"news");
行 44:             dr = ds.Tables["news"].Rows[0];
行 45:             //SqlCommand comm = new SqlCommand(sqlnews,sqlcon);
2008-04-08 22:47
馨馨
Rank: 1
等 级:新手上路
帖 子:136
专家分:0
注 册:2008-3-10
收藏
得分:0 
说43行有错,我的全部代码都给你看看把using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace zs
{
    /// <summary>
    /// newsshow 的摘要说明。
    /// </summary>
    public class newsshow : System.Web.UI.Page
    {
      
        protected System.Web.UI.WebControls.Label labtitle;
        protected System.Web.UI.WebControls.Label labnews;
        protected System.Web.UI.WebControls.Label labtime;
        protected System.Web.UI.WebControls.Label labname;

        public String newsid;
        public DataRow dr;

        private void Page_Load(object sender, System.EventArgs e)
        {// 在此处放置用户代码以初始化页面
            if(!IsPostBack)
                DataGridDataBind();
        }
        
        private void DataGridDataBind()
        {
            //取得上个页面传递来的参数值
            //newsid = Request.Params["newsid"];
            string newsid = Request.QueryString["newsid"];
            SqlConnection sqlcon = new SqlConnection("server=.;uid=sa;pwd=;database=community");
            //sqlcon.Open;//建立数据库连接
            string sqlnews="select * from news where newsid =" + newsid;
            SqlDataAdapter MyCommandnews = new SqlDataAdapter(sqlnews,sqlcon);//创建SqlDataAdapter对象,按照指定的查询语句获取结果
            DataSet ds = new DataSet ();//定义DataSet对象,将查询结果填充到这个对象上
            MyCommandnews.Fill(ds,"news");
            dr = ds.Tables["news"].Rows[0];
            //SqlCommand comm = new SqlCommand(sqlnews,sqlcon);
            //SqlDataReader dr = comm.ExecuteReader();
            
        }    
        //FormatString(string str)方法,改变字符串格式的方法
        protected string FormatString(string str)
        {
        str=str.Replace(" ","&nbsp;&nbsp;");
        str=str.Replace("<","&lt;");
        str=str.Replace(">","&gt;");
        str=str.Replace('\n'.ToString(),"<br>");
        return str;
        }

        #region Web 窗体设计器生成的代码
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 该调用是 Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }
        
        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {   
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion
    }
}
2008-04-08 22:48
快速回复:数据绑定
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026892 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved