如何在asp.net中使用linq创建搜索按钮 [英] How to make search button using linq in asp.net

查看:97
本文介绍了如何在asp.net中使用linq创建搜索按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在ASP.NET中使用linq制作搜索按钮,但我不知道该怎么做。



我正在使用这个代码,但结果没有出现:代码是:



I need to make "search button" using linq in ASP.NET, but I can't know how to do that.

I'm using this code, but the result didn't appear: the code is:

if(txtSearch.Text !=null)
{
   string query = string.Format("select * from PROJECTS where {0} like '%{1}%'"
                                                               , sender, e);
    query.ToList();
}

推荐答案

请阅读我对该问题的评论。



我建议你阅读: ASP.NET - LINQ [ ^ ]

< a href =http://weblogs.asp.net/scottgu/using-linq-to-sql-part-1>使用LINQ to SQL(第1部分) [ ^ ]

简单使用C#和VB.Net在ASP.Net网站中使用LINQ to SQL的示例教程 [ ^ ]



假设您想要动态创建查询,您可能对创建动态查询感兴趣。请参阅:

动态LINQ(第1部分:使用LINQ动态查询库) [ ^ ]

C#中的动态LINQ查询 [ ^ ]

动态查询示例 [ ^ ]
Please, read my comment to the question.

I'd suggest to read this: ASP.NET - LINQ[^]
Using LINQ to SQL (Part 1)[^]
Simple Tutorial with example of using LINQ to SQL in ASP.Net Website using C# and VB.Net[^]

Assuming that you want to create queries on the fly, you might be interested in createing dynamic queries. Please, see:
Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)[^]
Dynamic LINQ Query in C#[^]
Dynamic Query Sample[^]


var q =(来自db.PRODUCT中的c)其中c.ProductName == textBox1.Text选择c).ToList();
var q = ( from c in db.PRODUCT where c.ProductName == textBox1.Text select c).ToList();


这篇关于如何在asp.net中使用linq创建搜索按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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