如何在数据列表中查看球状表 [英] how to view perticular table in datalist

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

问题描述

datalistpage.aspx

datalistpage.aspx

protected void dlProfile_ItemCommand(object source, DataListCommandEventArgs e)
   {
       if (e.CommandName == "Details")
       {
           string FirstName = Convert.ToString(e.CommandArgument);

           Response.Redirect("ViewDetails.aspx?@UserId=" +ID);



       }
   }




ViewDetails.aspx




ViewDetails.aspx

protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["dbConnection"].ToString());
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "usp_JoinRegistration";
        cmd.Connection = con;
        con.Open();

        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        dlProfile.DataSource = dt;
        dlProfile.DataBind();

        cmd.Dispose();
        con.Close();  

    }



这是我的代码..问题正在检索所有表的详细信息..但我想检索数据列表中的选定表数据..任何人都可以帮助我..



here is my code..problem is m retrieving all tables details..but i want to retriev selected tables data in datalist..can anyone help me..

推荐答案

您正在从存储的过程中获取数据.
此过程未提供此代码,因此我不知道运行什么代码.

但是,您基本上需要修改存储过程以仅获取您感兴趣的那些列.
那将是解决此问题的最简单方法.
You are getting data from a stored procdure.
The code for this procdure is not provided here so I don''t know what code runs.

However, you basically need to modify the stored procedure to get only those columns you are interested in.
That would be the easiest approach to solve this problem.




更正您的代码,例如:
Hi,

Correct your code as example:
string studentId = "1234";
Response.Redirect("ViewDetails.aspx?en=" + studentId);




在您的ViewDetails.aspx代码后面:




in your ViewDetails.aspx code behind:

if (!IsPostBack)
{
    string id = Request.QueryString["en"].ToString();
    // Pass the id in your StoredProcedure
    // Some code here?...
    SqlCommand cmd = new SqlCommand("usp_JoinRegistration", conn)
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("@UserID", SqlDbType.NVarChar).Value = id ;
    // Some code here?...
}




检查您的存储过程. usp_JoinRegistration 应该有一个
为了过滤条件而传递的UserID参数...

请投票表决是否有帮助,以便其他人可以考虑作为答案...

问候




Check your Store proc. usp_JoinRegistration should have a
UserID parameter to pass in order to filter the condition...

Please vote if could help so that others may consider as an answer...

Regards,


这篇关于如何在数据列表中查看球状表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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