如何将值或数据从数据列表传递到面板 [英] how to pass values or data from datalist to panel

查看:147
本文介绍了如何将值或数据从数据列表传递到面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
自从最近几天以来,我试图将值从数据列表传递到面板,让我解释一下更多内容
我有一个数据列表,其中包含某项的一些初始信息,以及一个详细链接按钮,该按钮应在同一页上数据列表之外的面板上显示所选ID的值或数据
我知道如何将值从数据列表传递到另一个页面,就像这样

hi all
since last a few days i am trying to pass values from from a datalist to panel let me explain a bit more
i have a datalist which contains some initial info of an item and a detail link button which should display values or data of selected id on a panel which is outside the datalist on the same page
i know how to pass values from a datalist to another page which is some thing like this

protected void datalist_ItemCommand(object source, datalistCommandEventArgs e)
    {
        if (e.CommandName == "details")
        {
            Response.Redirect("./Repeater_DataSource.aspx?house_id=" + e.CommandArgument);

        }
    }


但不知道如何将值从数据列表传递到同一页上数据列表之外的面板,如果有人提出一个示例,我将深表感谢.
感谢


but dont know how can i pass values from datalist to panel outside the datalist on same page i will deeply appreciate if some one come up with an exampple
thanks

推荐答案

protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "Select")
        {
            string id = e.CommandArgument.ToString();
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["yourconnection"].ConnectionString);
            con.Open();
            SqlCommand com = new SqlCommand("select * from homes where id=" + id, con);
            SqlDataAdapter da = new SqlDataAdapter(com);
            DataSet ds = new DataSet();
            da.Fill(ds);
            childdatalist.DataSource = ds.Tables[0];
            childdatalist.DataBind();

        }
    }


if (e.CommandName == "details")
        {
            Response.Redirect("./Repeater_DataSource.aspx?house_id=" + e.CommandArgument.ToString());

        }




并在下一页从查询字符串中获取ID值.然后将此ID作为参数传递来获取值.




And in the next page get the id value from the query string.Then pass this id as a parameter to get the values.


<a href='<%# Eval("house_id","~/foldername/Repeater_DataSource.aspx?house_id={0}")%>'>
"your Iteltem Here Like Imge button "
<a>


这篇关于如何将值或数据从数据列表传递到面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆