0

在网格视图上,我添加了一个按钮。当我单击按钮时,我将状态从 0 更改为 1,然后我想在单击按钮时刷新页面。请告诉我我该怎么做?

4

2 回答 2

0

      public ActionResult Index()
        {
            string odabir = Request.Form["unos"];
            TempData["odabir"] = odabir;
            return View();
        }
        public ActionResult prikaz() {
            string putanja = TempData["odabir"].ToString();
            string xmlPutanja = @"C:\Users\BAJAGA\Documents\Visual Studio 2012\Projects\mvc\andrijamvc\" + putanja + ".xml";
            List <raspored> raspored = new List<raspored>();
            XmlDocument doc = new XmlDocument();
            doc.Load(xmlPutanja);
            foreach (XmlNode cvor in doc.SelectNodes("/skola/Raspored"))
            {
                raspored.Add(new raspored
                {
                    rb = cvor["Rbr"].InnerText,
                    dan = cvor["DanUNedelji"].InnerText,
                    predmets = cvor["Predmet"].InnerText
                }
                );
            }
            return View(raspored);
        }

    }
}
@*@{
    ViewBag.Title = "prikaz";
}
@Html.ActionLink("nesto","Index","Home")
<h2>prikaz</h2>
<table border="20">
    <tr>
        <th>Redni br</th>
        <th>Ponedeljak</th>
        <th>Utorak</th>
        <th>Sreda</th>
    </tr>
    @foreach (andrijamvc.Models.raspored rp in Model)
    {
        <tr>
            <td>@rp.rb</td>
           <td>@rp.predmets</td> 
        </tr>
    }
    
</table>*@
@*@{
    ViewBag.Title = "Index";
}
@Html.ActionLink("Prikaz", "prikaz", "home");
@using(Html.BeginForm("Index","home")){
<h2>Index</h2>
<form>
Unesi ime fajla:<input type="text" name="unos" />
    <input type="submit" />
    </form>
}*@

于 2019-06-08T11:19:46.857 回答
-1

在网格属性中添加这个

OnDataBound ="Gridview_Bond"

在后面的代码中 -

protected void Gridview_Bond(object sender, EventArgs e)
    {
       Gridview.DataBind();
       Page.DataBind()

    }
于 2012-05-27T05:54:21.943 回答