Hi, I'm using a Grid inside a TabStrip and a Combobox for filtering. First time it loads correctly, but after I do a postback from the ComboBox it loads only the PartialPage instead of reloading the Partial inside the TabStrip.
div class="btn-group">
@using (Ajax.BeginForm("Rules", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "Rules", InsertionMode = InsertionMode.Replace }))
{
@Html.AntiForgeryToken()
<
label
>Account No</
label
>
@(Html.Kendo().DropDownList()
.Name("selectedAccountNo")
.DataTextField("Value")
.DataValueField("Text")
.BindTo(Model.selectedAccNo)
.HtmlAttributes(new { style = "width: 100%" })
)
<
br
/>
<
label
> Application </
label
>
@(Html.Kendo().DropDownList()
.Name("selectedAppNo")
.DataTextField("Value")
.DataValueField("Text")
.BindTo(Model.selectedAppNo)
.HtmlAttributes(new { style = "width: 100%", @onchange = "this.form.submit();" })
)
}
</
div
>
01.
[HttpPost]
02.
[ValidateAntiForgeryToken]
03.
public
ActionResult Rules(
string
selectedAccountNo =
""
,
string
selectedAppNo =
""
)
04.
{
05.
var rules = from rule
in
_db.Rules
06.
select rule;
07.
08.
var ruletypes = from rTypes
in
_db.RuleTypes
09.
select rTypes.RuleType1;
10.
11.
var vm =
new
RuleListAndSearchVM(_db);
12.
var rulesVm =
new
List<RuleVM>();
13.
14.
ViewBag.Title =
"Rules"
;
15.
16.
17.
var ruleTypes = _db.RuleTypes.AsNoTracking().Select(n =>
new
SelectListItem { Value = n.RuleTypeId.ToString(), Text = n.RuleType1 }).ToList();
18.
ViewBag.RuleType = ruleTypes;
19.
TempData.ContainsKey(
"RuleType"
);
20.
vm.RuleType = ruleTypes;
21.
22.
List<SelectListItem> appNumbers = _db.Rules.AsNoTracking().Select(n =>
new
SelectListItem { Value = n.AppNo, Text = n.AppNo }).ToList();
23.
List<SelectListItem> accNumbers = _db.Rules.AsNoTracking().Select(n =>
new
SelectListItem { Value = n.AccNo, Text = n.AccNo }).ToList();
24.
vm.selectedAppNo = appNumbers;
25.
vm.selectedAccNo = accNumbers;
26.
27.
if
(!String.IsNullOrEmpty(selectedAccountNo))
28.
{
29.
rules = rules.Where(acc => acc.AccNo == selectedAccountNo);
30.
}
31.
if
(!String.IsNullOrEmpty(selectedAppNo))
32.
{
33.
rules = rules.Where(acc => acc.AppNo == selectedAppNo);
34.
}
35.
36.
37.
foreach
(var r
in
rules)
38.
{
39.
var newRule =
new
RuleVM() { AccNo = r.AccNo, AppNo = r.AppNo, RuleId = r.RuleId, RuleType =
new
RuleTypeVM() { RuleTypeId = r.RuleTypeId }, RuleValue = r.RuleValue, CreatedBy =
new
UserVM() { UserId = r.CreatedBy }, DateCreated = r.DateCreated };
40.
41.
if
(r.Status ==
true
)
42.
newRule.Status =
"Active"
;
43.
else
44.
newRule.Status =
"Deleted"
;
45.
46.
newRule.RuleType.RuleType = _db.RuleTypes.Find(newRule.RuleType.RuleTypeId).RuleType1;
47.
newRule.CreatedBy.Username = _db.Users.Find(newRule.CreatedBy.UserId).Username;
48.
rulesVm.Add(newRule);
49.
50.
}
51.
52.
vm.Data = rulesVm;
53.
54.
vm.SelectedAccNo = selectedAccountNo;
55.
vm.SelectedAppNo = selectedAppNo;
56.
57.
if
(!
string
.IsNullOrEmpty(selectedAccountNo) || !
string
.IsNullOrEmpty(selectedAppNo))
58.
{
59.
View(
"RulesPartial"
, vm).ExecuteResult(
this
.ControllerContext);
60.
return
View(
"RulesPartial"
, vm);
61.
}
62.
63.
return
new
HttpStatusCodeResult(HttpStatusCode.BadRequest);
64.
65.
}