C# 如何在ASP.Net中选择和提交数据,以及如何在同一页面上显示来自另一个表的数据
按下搜索按钮时,数据应显示在下表中 控制器C# 如何在ASP.Net中选择和提交数据,以及如何在同一页面上显示来自另一个表的数据,c#,asp.net,.net,sql-server,database,C#,Asp.net,.net,Sql Server,Database,按下搜索按钮时,数据应显示在下表中 控制器 public ActionResult getStudentClass(int Grade, string ABC) { // int CId; if (!String.IsNullOrEmpty(ABC)) { var items = _context.Class.Where(x => x.Grade == Grade & x
public ActionResult getStudentClass(int Grade, string ABC)
{
// int CId;
if (!String.IsNullOrEmpty(ABC))
{
var items = _context.Class.Where(x => x.Grade == Grade & x.ABC == ABC).ToList();
// CId = "";
string CId = "";
for (int i = 0; i <= items.Count - 1; i++)
{
CId += "<tr>" +
"<td>" + items[i].ABC + "</td>" +
"<td>" + items[i].classId + "</td>" +
"<td>" + items[i].classMonitor + "</td>" +
//"<td>" + items[i]. + "</td>" +
"</tr>";
}
TempData["Table"] = CId;
}
return RedirectToAction("index");
}
public ActionResult getStudentClass(int-Grade,string-ABC)
{
//int-CId;
如果(!String.IsNullOrEmpty(ABC))
{
var items=_context.Class.Where(x=>x.Grade==Grade&x.ABC==ABC.ToList();
//CId=“”;
字符串CId=“”;
对于(int i=0;i您正在使用哪个数据库…?…在问题中添加标记im使用SQL Server 2016从tbl_YourTableName WHERE Grade='1'和Classs='A'中选择RegNo、NAME、Status欢迎使用堆栈溢出黑暗面。您可以详细说明您的问题吗?目前,很难知道您面临的确切问题以及如何提供answer.使用partialview显示新表或使用Jquery填充预先存在的第二个表