mvc gridview在选择过滤器时使用html返回弹出窗口或单击下一页如何在此代码中修复此问题显示我的部分gridview我的视图和控制器操作
PartialView
@{
Html.DevExpress().GridView(settings =>
{
settings.Name = "TestList";
settings.CallbackRouteValues = new { Controller = "Admin", Action = "TestList" };
settings.CommandColumn.Visible = true;
settings.KeyFieldName = "ID";
settings.CommandColumn.Visible = false;
settings.Columns.Add(column =>
{
column.Caption = "Edit";
column.Visible = true;
column.SetDataItemTemplateContent(content =>
ViewContext.Writer.Write(
Html.ActionLink("Edit", "TestListEdit", "admin",
new { id = content.KeyValue }, null)));
});
settings.Columns.Add(column =>
{
column.Caption = "Delete";
column.Visible = true;
column.SetDataItemTemplateContent(content =>
ViewContext.Writer.Write(
Html.ActionLink("Delete", "TestListDelete", "admin",
new { id = content.KeyValue }, null)));
});
settings.Columns.Add(column =>
{
column.Caption = "Manage";
column.Visible = true;
column.SetDataItemTemplateContent(content =>
ViewContext.Writer.Write(
Html.ActionLink("Manage Questions", "ManageQuestions", "admin",
new { id = content.KeyValue }, null)));
});
settings.SettingsBehavior.AllowSelectByRowClick = true;
settings.Columns.Add("ID");
settings.Columns.Add("Title");
settings.Columns.Add("Description");
settings.Columns.Add("Lang_ID");
settings.Columns.Add("TryDescription");
}).Bind(Model).Render();
}
这是我的观点
@model List<FastCreditTraining.Models.AdminTestListEditingModel>
@{
ViewBag.Title = "TestList";
Layout = "~/Views/Shared/_adminLayout.cshtml";
}
@{
List<SelectListItem> listItems = new List<SelectListItem>();
listItems.Add(new SelectListItem
{
Text = "English",
Value = "1"
});
listItems.Add(new SelectListItem
{
Text = "Հայերեն",
Value = "2",
});
}
<body>
<div style="display:inline-block;float:right; margin-right:30px; margin-top:10px">
@Html.ActionLink("Create", "TestListCreate", "admin", new { @class = "LangButton" })
</div>
<div style="display:inline-block">
<form style="display:inline-block" name="tActive" id="tActive" method="get">
<div style="margin-left:50px; display:inline-block;">
<p style="display:inline-block">@Resources.Resource.DisplayActiveTests</p>
@Html.CheckBox("tActive", true)
</div>
<div style="margin-left:100px; display:inline-block;">
<p style="display:inline-block">@Resources.Resource.SetLanguageInterfaceEdit</p>
@Html.DropDownList("langSwitch", listItems)
</div>
<input type="submit" name=" asdasd" value="Filter">
</form>
</div></body>
@{Html.RenderPartial("_GridViewTestListPartial",Model);}
这是我的控制器动作
![\[Authorize\]
public ActionResult TestList(string tActive, string langSwitch)
{
//tActive and langSwitch choose getting tests with procedure getTests_Result
List model1;
if (tActive == null || langSwitch == null)
{
model1 = db.getTests(true, 1).ToList();
}
else
{
model1 = db.getTests(Convert.ToBoolean(tActive), Convert.ToInt32(langSwitch)).ToList();
}
///////////////////end of getting///////////////////
// Fill new created model from database test lists and departaments and positions
List _Departments = db.T_Department_Lang.ToList();
List _Positions = db.T_Position_Lang.ToList();
List _checkForDep = new List();
List _checkForPos = new List();
foreach (var item in _Departments)
{
_checkForDep.Add(new bool());
}
foreach (var item in _Positions)
{
_checkForPos.Add(new bool());
}
for (int i = 0; i < model1.Count; i++)
{
allModels.Add(new AdminTestListEditingModel()
{
ID = model1\[i\].ID,
Date_Added = model1\[i\].Date_Added,
Limit = model1\[i\].Limit,
IS_Active = model1\[i\].IS_Active,
Allow_Back = model1\[i\].Allow_Back,
Title = model1\[i\].Title,
Description = model1\[i\].Description,
Lang_ID = model1\[i\].Lang_ID,
S_Changed = model1\[i\].S_Changed,
Question_qnt = model1\[i\].Question_qnt,
Pos_Save = model1\[i\].Pos_Save,
Question_test_qnt = model1\[i\].Question_test_qnt,
TryDescription = model1\[i\].TryDescription,
qCount = model1\[i\].qCount,
TestList_Id = model1\[i\].ID,
Departments = _Departments,
Positions = _Positions,
checkForDep = _checkForDep,
checkForPos = _checkForPos
});
}
//////////////// end fill //////////////////
Session\["allModels"\] = allModels;
return View(allModels);
}][1]
答案 0 :(得分:3)
返回 PartialView 而非查看以解决此问题:
//return View(allModels);
return PartialView(allModels);
请参阅Why can the alert message with the HTML/JavaScript/CSS content appear when using callback-aware extensions?知识资源以了解详情。