C# 将滚动条添加到RadioButtonList
我有一个RadioButtonList,它包含很多项,所以我需要添加一个垂直滚动条。这是我向RadioButtonList添加项的代码C# 将滚动条添加到RadioButtonList,c#,asp.net,C#,Asp.net,我有一个RadioButtonList,它包含很多项,所以我需要添加一个垂直滚动条。这是我向RadioButtonList添加项的代码 var Meals = Factory.Meals.List(); var MealVotes = Factory.MealVotes.List(item => item.VoteDate == DateTime.Today); var MealVote = Factory.MealVotes.List(item => ite
var Meals = Factory.Meals.List();
var MealVotes = Factory.MealVotes.List(item => item.VoteDate == DateTime.Today);
var MealVote = Factory.MealVotes.List(item => item.VoteDate == DateTime.Today && item.UserId == Instance.CurrentUserId).ToList().FirstOrDefault();
foreach (var meal in Meals)
{
mealVotes = 0;
TotalVotes = 0;
foreach (var mealVote in MealVotes)
{
if (meal.Id == mealVote.MealId)
{
mealVotes++;
}
TotalVotes++;
}
if (TotalVotes > 0)
{
Width = (100M / TotalVotes) * mealVotes;
};
VoteMealRadioButtonList.Items.Add(
new ListItem(
meal.Title + " " + mealVotes +
@"<div style=""height: 10px; width:130px;"">" +
@"<a style=""float: left; width: 30px""></a>" +
@"<div style=""float: left; height: 10px; width:" + Width + @"px; background: DarkCyan;""></div>" +
"</div>",
meal.Id.ToString()
)
);
}
VoteMealRadioButtonList.SelectedValue = MealVote.MealId.ToString();
var-fines=Factory.fines.List();
var MealVotes=Factory.MealVotes.List(item=>item.VoteDate==DateTime.Today);
var MealVote=Factory.MealVotes.List(item=>item.VoteDate==DateTime.Today&&item.UserId==Instance.CurrentUserId.ToList().FirstOrDefault();
foreach(每餐中的每餐)
{
mealVotes=0;
总票数=0;
foreach(MealVotes中的var mealVote)
{
if(mean.Id==mealVote.MealId)
{
mealVotes++;
}
总票数++;
}
如果(总票数>0)
{
宽度=(100米/总票数)*米票数;
};
VoteMealRadioButtonList.Items.Add(
新列表项(
餐名+“”+mealVotes+
@"" +
@"" +
@"" +
"",
膳食Id.ToString()
)
);
}
VoteMealRadioButtonList.SelectedValue=MealVote.MealId.ToString();
看起来是这样的:
不要担心清单和餐名(用我的母语)。如果列表中有这么多的食物,这不会是一个问题,但是会有50顿或类似的食物,所以我想添加一个垂直滚动条
还有我可以添加滚动条的地方吗?为什么不将radiobuttonlist放到一个div中,然后将滚动条添加到这个div中?radiobuttonlist已经在div中了。我不知道我可以先把卷轴放进div。谢谢,现在已经解决了:)