This is what I got on the web:
In Controller:
int count = ems.SupportAdds.Where(x=>x.ArticleId == id).Count();
var stringArray = new string[count]{"",""}; //Here,I want to fetch data from table.
ViewBag.Collection = stringArray;
But, I want to send data dynamically which will come from the database using entity framework.
In View :
@for (int i = 0; i <= Count; i++)
{
@Html.LabelFor(model => @item.supportAdd.Title)
<input type="text" name="Title[]" id="HeadingTitle"
Value="@Html.Raw(ViewBag.Collection[i])"/>
}
我没有得到控制器如何将数据发送到视图的逻辑。
我无法发送数据集来查看。
以前,我习惯使用viewbag发送,但这是运行时绑定错误。
我不知道如何解决它。
答案 0 :(得分:0)
要将任何集合值传递给View,您可以使用foreach获取每个值
在控制器:
var stringArray = new string[]
{
"Manual", "Semi", "Auto", "SSS"
};
ViewBag.Collection = stringArray;
在查看
中foreach(var p in ViewBag.Collection)
{
@for (int i = 0; i <= Count; i++)
{
@Html.LabelFor(model => @item.supportAdd.Title)
<input type="text" name="Title[]" id="HeadingTitle" value="@p"/>
}
}
- 此代码未经过测试
答案 1 :(得分:0)
UINavigationBar.appearance().backIndicatorImage = image.withRenderingMode(.alwaysOriginal)
UINavigationBar.appearance().backIndicatorTransitionMaskImage = image.withRenderingMode(.alwaysOriginal)
if #available(iOS 11, *) {
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .normal)
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .highlighted)
} else {
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: -60, vertical: -60), for: .default)
}