我有一个gridview,我正在填写会计人员的数据,他们希望我格式化货币值,使它们显示没有$,用逗号分隔数字和负号由()包围
例如:
12345.67 = 12,345.67
-12345.67 =(12,345.67)
我发现很多关于互联网的例子让我很接近但是在负面附近没有()或者包含$.
我有一组用户可以选择的问题,其中一些问题有一个可供选择的辅助选项列表.我的目标是有一个下拉列表,如果你选择其中一个选项,其中包含其SecondaryChoiceList中的项目,那么第二个列表将出现在初始下拉列表下方,所有这些都将被强类型并在提交时绑定到模型.
我可以通过以下方式获得初始列表:
@Html.DropDownListFor( x => x.SelectedChoiceId, new SelectList(Model.Choices, "Id", "Name"))
Run Code Online (Sandbox Code Playgroud)
但是,这与辅助列表没有挂钩,我完全迷失了如何将该辅助列表与我提交表单时返回的模型联系起来.
这是我的视图模型:
public class ExampleViewModel
{
public List<Choice> ChoiceList { get; set; }
public int SelectedChoiceId { get; set; }
public int SelectedAffiliateId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
以下是选择的样子:
public class Choice
{
public int Id { get; set; }
public string Name { get; set; }
public IEnumerable<SecondaryChoice> SecondaryChoiceList { get; set; }
public Choice()
{
SecondaryChoiceList = new List<SecondaryChoice>();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的SecondaryChoice对象:
public class EligibleAffiliate
{
public int …Run Code Online (Sandbox Code Playgroud) 我正在尝试将API用于众所周知的在线会议提供商.其中一个API调用返回一个如下所示的对象.
{
"5234592":{
"pollsAndSurveys":{
"questionsAsked":1,
"surveyCount":0,
"percentageSurveysCompleted":0,
"percentagePollsCompleted":100,
"pollCount":2},
"attendance":{
"averageAttendanceTimeSeconds":253,
"averageInterestRating":0,
"averageAttentiveness":0,
"registrantCount":1,
"percentageAttendance":100}
},
"5235291":{
"pollsAndSurveys":{
"questionsAsked":2,
"surveyCount":0,
"percentageSurveysCompleted":0,
"percentagePollsCompleted":0,
"pollCount":0},
"attendance":{
"averageAttendanceTimeSeconds":83,
"averageInterestRating":0,
"averageAttentiveness":0,
"registrantCount":1,
"percentageAttendance":100}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图在C#中创建一个强类型对象,以便我可以处理这些数据.我可以为pollsAndSurveys位和出勤位创建对象,但我不知道如何处理id号,在本例中为5234592和5235291,这是会话的标识符.
public class AttendanceStatistics
{
[JsonProperty(PropertyName = "registrantCount")]
public int RegistrantCount { get; set; }
[JsonProperty(PropertyName = "percentageAttendance")]
public float PercentageAttendance{ get; set; }
[JsonProperty(PropertyName = "averageInterestRating")]
public float AverageInterestRating { get; set; }
[JsonProperty(PropertyName = "averageAttentiveness")]
public float AverageAttentiveness { get; set; }
[JsonProperty(PropertyName = "averageAttendanceTimeSeconds")]
public float …Run Code Online (Sandbox Code Playgroud)