DropDownList + Autopostback + Paramètres dans l'URL = Problèmes :/
Salut :)
Je reviens encore une fois vers vous pour cette fois-ci un problème d'Autopostback qui me vire mes paramètres passés dans l'URL...
Dans la vue de mon action Index de mon contrôleur Suivi, j'ai des images avec lien vers une autre action de mon contrôleur, l'action PageDomaines :
Code:
1 2 3
|
<a href="@Url.Action("PageDomaines", new { Controller = "Suivi", CR = VarCR, Appli = VarAppli[j] })">
<img src="../../Content/Images/feu_rouge.png" alt="Statut OK" border="0" /></a> |
Comme vous pouvez le voir, j'envoie des paramètres via l'URL (CR et Appli) à mon action PageDomaines, jusque là tout va bien, je les récupère bien et effectue bien ma requête avec les paramètres renvoyés et qui fonctionne.
Ensuite dans la vue de mon action PageDomaines, j'ai une DropDownList effectuant un autopostback (enfin même avec un bouton Submit, ça me le fait donc bon...) renvoyant une certaine valeur à mon action qui ensuite effectue une requête en fonction de celle-ci.
Mais lorsque je sélectionne une valeur, mes paramètres disparaissent dans un trou noir intersidéral (au moins) et c'est la merde :aie:
J'ai absolument besoin de conserver ces paramètres afin d'afficher la bonne page.
Voici ma liste en question :
Code:
1 2 3 4 5
|
@using (Html.BeginForm("PageDomaines", "Suivi"))
{
@Html.DropDownList("DDL", new SelectList(new[] { "MMCR", "MMCL", "MMCO", "MMSE", "MMAS" }), "--Select one--", new { onchange = "this.form.submit();" })
} |
Et mon action PageDomaines :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
public ActionResult PageDomaines(string CR, string Appli, string DDL)
{
string GetCR = CR;
string GetAppli = Appli;
string GetDDL = DDL;
if (GetDDL == null)
{
var items = GetDomaines();
int Var1 = DateTime.Now.Year;
int Var2 = DateTime.Now.Month;
string Var3 = "" + Var1 + Var2;
var Query = (from i in items
where i.Field<String>("CD_APPLI") == GetAppli && i.Field<String>("CD_CR") == GetCR && i.Field<Int64>("PERIODE").ToString().Contains(Var3)
select new Suivi { CD_TRT = i.Field<String>("CD_TRT"), LB_TRT = i.Field<String>("LB_TRT"), CD_CR = i.Field<String>("CD_CR"), PERIODE = i.Field<Int64>("PERIODE"), CD_APPLI = i.Field<String>("CD_APPLI"), STATUT = i.Field<String>("STATUT") }).ToList();
ViewData["CR"] = GetCR;
ViewData["Appli"] = GetAppli;
return View(Query);
}
else
{
var items = GetDomaines();
int Var1 = DateTime.Now.Year;
int Var2 = DateTime.Now.Month;
string Var3 = "" + Var1 + Var2;
var Query = (from i in items
where i.Field<String>("CD_APPLI") == GetAppli && i.Field<String>("CD_CR") == GetCR && i.Field<Int64>("PERIODE").ToString().Contains(Var3) && i.Field<String>("CD_TRT") == GetDDL
select new Suivi { CD_TRT = i.Field<String>("CD_TRT"), LB_TRT = i.Field<String>("LB_TRT"), CD_CR = i.Field<String>("CD_CR"), PERIODE = i.Field<Int64>("PERIODE"), CD_APPLI = i.Field<String>("CD_APPLI"), STATUT = i.Field<String>("STATUT") }).ToList();
ViewData["CR"] = GetCR;
ViewData["Appli"] = GetAppli;
return View(Query);
}
} |
Savez-vous comment je pourrais faire pour conserver mes paramètres lorsque je sélectionne ma valeur dans la liste ?
J'espère avoir été assez clair, merci d'avance pour votre aide :)