【发布时间】:2011-03-21 13:18:16
【问题描述】:
我正在使用asp.net mvc3.0 razor框架和html Table在ViewBag的帮助下绑定数据。我必须根据下拉列表中的选定选项显示数据。
public ActionResult Index(GetFileName fn)
{
....
ViewBag.Grid1Data =dt;
return View();
}
第一次,我得到了数据,但是下次当从下拉列表中选择另一个选项来获取第二个表时,该表没有显示,但我正在获取数据。
查看包括 下拉
<select id="Select2">
<option>Select</option>
<option>abc</option>
<option>des</option>
<option>fgh</option>
<option>next</option>
<option>first</option>
</select>
// Heading for the table
<h2>@ViewBag.Heads</h2>
// Table
<table id="table" cellpadding="10px" cellspacing="0" class="TableSty">
@for (int j = 0; j < ViewBag.Grid1Data.Rows.Count; j++)
{
var color = "";
if (j % 2 == 0)
{ color = "#f2f2f2"; }
else { color = "white"; }
<tr style="background:@color" >
@for (int c = 0; c < @ViewBag.Grid1Data.Columns.Count; c++)
{
<td class="data">@ViewBag.Grid1Data.Rows[j][c].ToString()
</td>
}
</tr>
}
</table>
请帮我解决问题
【问题讨论】:
-
我们可以看到您的视图,包括任何脚本吗?
标签: javascript asp.net html asp.net-mvc-3