从SQL获取结果并在gridview按钮单击的第二页上显示 [英] Fetch results from SQL and display on second page on gridview button click

查看:52
本文介绍了从SQL获取结果并在gridview按钮单击的第二页上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



需要你的帮助..

我有两个aspx页面。

First页面有一个gridview,其中包含选定列Name,PhoneNumber,Age,City和每行的查看详细信息按钮。结果是从sql中获取的。

我有另外一页超过80个字段的页面被3个标签分隔,每个字段都有一个标签在它前面。

我想要的是当用户点击视图详细信息时,它应该将其重定向到第二页并显示基于所选行的记录。另请注意,这80个字段存储在sql中的不同数据库中,gridview值从不同的数据库中获取,但两个数据库都有Name,Age和City等公共字段,因此数据应该在第二个字段中获取页面基于以上3列。



我真的非常需要你的帮助,非常感谢。

提前致谢。



我尝试了什么:



我搜索了不同的网站,但我不能找到类似我的问题。

Hello guys,

Need your help..
I have two aspx pages.
First page has a gridview with selected columns "Name", "PhoneNumber" , "Age", "City" and a button " View Details" against each row. The results are fetched from sql .
I have another page with more than "80 fields" seperated by "3 tabs" and every field has a label infront of it.
What i want is when a user clicks on view details, It should redirect it to the second page and display records based on the selected row. Also note that that these 80 fields are stored in different database in sql and the gridview values are fetched from different database but both databases have common fields like "Name" , "Age" and "City", so the data should be fetched in second page based on above 3 columns.

I really need your help here and would highly appreciate it.
Thanks in advance.

What I have tried:

I have searched different sites but i could not find a similar problem as mine.

推荐答案

读取此使用QueryString在页面之间传递变量 [ ^ ]


实际上很简单。

让我们忘记你如果要求只是导航到具有一些唯一标识的另一个页面,则单击按钮。它可以通过简单的超链接/锚标签来完成。



让我们看看代码需要如何修改(仅供参考) -



Gridview:

It's pretty easy actually.
Let's forget about the button click, if the requirement is just to navigate to another page with some unique identification. It can be done through just simple hyperlink/anchor tag.

Let's see, how the code need to be modified (just for reference)-

Gridview:
<asp:templatefield headertext="Action">
   <itemtemplate>
      <a href="yourSecondPage?id='<%#Eval(" youruniqueid")="" %="">'">Click</a>
   </itemtemplate>
</asp:templatefield>



在第二页(可能是页面加载事件)中,检查是否页面附带一个名为id的查询字符串,并调用一个方法来绑定第二页中的gridview。



类似于以下内容 -


In the second page (in probably the page load event), check if page came with a querystring named "id" and call a method to bind the gridview in the second page.

Something similar to following-

if(!Page.IsPostback)
{
  if(Request.QueryString["id"] != null)
  {
     bindMyGridviewWith80Fields(Request.QueryString["id"]);
  }
}





希望,它有帮助:)

如果有如果我在这里遗漏了任何疑问,请告诉我。



Hope, it helps :)
If there are further doubts or in case I have missed anything here, please let me know.


这篇关于从SQL获取结果并在gridview按钮单击的第二页上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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