使用mvc在mutlipe表中搜索数据。使用单个文本框和按钮 [英] searching for data in mutlipe tables using mvc. using a single textbox and button

查看:54
本文介绍了使用mvc在mutlipe表中搜索数据。使用单个文本框和按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我正在尝试在我的管理页面上执行搜索..我想要搜索的是在我拥有的所有不同表格中查找数据..例如,我有一名学生控制员和员工控制员。我想使用一个文本框和一个按钮执行搜索,但能够搜索员工表和学生表..此时我可以为每个控制器创建一个搜索..



例如。



客户控制器方法

hello

I am trying to perform a search on my Admin page.. what I want the search to do is find data in all different tables that I have.. eg I have a student controller and employee controller. I want to perform a search using one textbox and one button but be able to search both employee table and student table.. at the moment I am able to create one search per controller..

eg.

customer controller method

public ActionResult search(string id)
     {
         var cust = from x in db.customers
                    where
                        x.cust_Name.Equals(id)
                    select x;
         return View(cust.ToList());

     }





客户指数





customer index

<h3>Enter name to search for customer details</h3>
<form action="search" method="get">
    <img src="~/Images/search.png" /><input type="text" name="id" /><input type="submit" value="search" class="but" />
    <table>





我真的很感激帮助

谢谢



I would really appreciate the help
thank you

推荐答案

试试这样

http://stackoverflow.com/questions/9279741/mvc3- html-beginform-search-returning-empty-querystring [ ^ ]

希望这有助于
Try like this
http://stackoverflow.com/questions/9279741/mvc3-html-beginform-search-returning-empty-querystring[^]
Hope this helps


这篇关于使用mvc在mutlipe表中搜索数据。使用单个文本框和按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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