将URL绑定到数据库ID [英] Binding an URL to a database id

查看:114
本文介绍了将URL绑定到数据库ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将id绑定到URL。我希望我的aspx页面上的gridview使用我在数据库中提供的ID进行过滤。我希望通过我的URL访问此过滤器(product.aspx? Id = 1 );



我该怎么做?

解决方案

您好,



这可以帮到你...





http://www.aspdotnet-suresh.com/2011/01/how-to-delete-records-in-gridview-with.html [ ^ ]


你想要实现的东西可以通过名为 Query Strings 的概念来实现。请参阅下面的链接,以便更好地了解查询字符串是什么以及如何使用它们。



ASP QueryString Collection [ ^ ]



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



使用C#,VB.NET中的示例在Asp.net中查询字符串 [ ^ ]



asp.net QueryString示例:如何使用QueryString [ ^ ]





您将传递数据类似



 Response.Redirect (  Webform2.aspx?Name = + this.txtName.Text +  & LastName = + this.txtLastName.Text); 





并检索数据,例如



 txtBox1.Text = Request.QueryString [ 名称]; 
txtBox2.Text = Request.QueryString [ LastName];


1。只需将gridview绑定到sqldatasource,您可以在其中自定义查询的输入参数类型。



ex:您可以传递查询字符串或(ID)作为选择参数在SqlDatasource中。



2.如果你通过代码绑定它,即数据集或数据表,你可以在它在gridview中反映的Page_load上查询它。



DataTable.Select()方法......



参考视图这个 [ ^ ]


Im trying to bind an id to an URL. I want the gridview I have on my aspx page to filter using the ID I gave in my database. I want this filter to be accessed through my URL ("product.aspx?Id=1");

How do I do this?

解决方案

Hi,

This may help you...


http://www.aspdotnet-suresh.com/2011/01/how-to-delete-records-in-gridview-with.html[^]


The thing you are trying to achieve can be accomplished through the concept called Query Strings. Refer to below links to get better idea what query strings are and how to work with the same.

ASP QueryString Collection[^]

Passing variables between pages using QueryString[^]

Query String in Asp.net with Example in C#, VB.NET[^]

asp.net QueryString example: how to use QueryString[^]


You will pass data something like

Response.Redirect("Webform2.aspx?Name=" +this.txtName.Text + "&LastName=" +this.txtLastName.Text);



and retrieve data like

txtBox1.Text = Request.QueryString["Name"];
txtBox2.Text = Request.QueryString["LastName"];


1. just bind the gridview to the sqldatasource where you can customize the type of input parameter for the query.

ex: you can pass the querystring or (ID) as the selectparameter in SqlDatasource.

2. if you are binding it through code i.e., Either Dataset or Datatable you can query it on the Page_load it reflects in the gridview.

DataTable.Select() method...

for reference view this [^]


这篇关于将URL绑定到数据库ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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