在ASP.Net中使用Querystring绑定GridView [英] Bind GridView using Querystring in ASP.Net

查看:108
本文介绍了在ASP.Net中使用Querystring绑定GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我正在使用ASP.net2005.

我想使用查询字符串绑定网格视图.

假设我发送了URL的邮件.当用户基于该链接单击该URL时,我想绑定Grindview和在屏幕上显示

致谢和问候,
Nikunj Chheda.

Hi..

I m Using ASP.net 2005.

i want to Bind Grid View Using Query String.

suppose i sent mail of URL. when user clicks on that URL based on that link i want to bind Grindview and Display on Screen

Thnaks & Regards,
Nikunj Chheda.

推荐答案

请不要一遍又一遍地问同一个问题.这个问题无法回答.当前将网格绑定到什么取决于您.我们不知道那是什么.我们也不知道您绑定的内容为何会有所不同.因此,我们无法回答您.理想情况下,当页面改变显示内容时,例如网格内的页面或过滤器,它将通过使用查询字符串上的指令重定向到自身来实现.这样,您的URL就可以使用.
PLEASE stop asking variations of the same question over and over. This question can''t be answered. What you bind your grid to currently is up to you. We don''t know what it is. We also don''t know why what you bind to can vary. So, we can''t answer you. Ideally, when your page varies what it shows, such as the page within the grid, or a filter, it would do that by redirecting to itself with instructions on the query string. Then your URL will work.


当您向用户发送电子邮件时,向他发送带有查询字符串的链接,并在querystring参数中设置userID.当用户收到该邮件时,他将单击链接并重定向到您在链接中设置的页面.在该页面中,您必须从查询字符串中获取useId,并根据该值从数据库中获取相关事件数据并绑定gridview.
When you send the email to user send him a link with a querystring and set the userID in the querystring parameter. When the user receive that mail he will click the link and redirect to the page which you set in link. In that page you have to get the useId from querystring and on the basis of that value you can fetch the relevent data from your database and bind the gridview.


In body section you have to set 
<a href="http://www.yoursite.com/yourpage.aspx?uid=abc101"></a>

I am talking about email body where you have to set this.
When user click this link this link will take to user to yourpage.aspx with userid and you have to get the valude from query strig.

   Dim getval As String = Request.QueryString("uid").ToString()

now you do like 

Dim cmd as new sqlcommand("Select * from User where userid=''"& getval &"''",conn)

       If con.State = ConnectionState.Closed Then
            con.Open()
        End If
        Dim dr As SqlDataReader
          dr = cmd.ExecuteReader
        
            GridView1.DataSource = dr
            GridView1.DataBind()
     
      

        con.Close()


这篇关于在ASP.Net中使用Querystring绑定GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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