私はそのアイテムの一部をチェックしたいチェックボックスリストを持っています。 データベースにストアをチェックしたいのですが、データベースから選択してループしていますが、最後に選択したアイテムです:((:checkboxlistの項目をチェックする方法は?
var selectedRoles = (from r in DataContext.Context.Core_PagesPermission
where r.PageName.Contains(pageName) select r)
.FirstOrDefault();
if(selectedRoles != null)
{
string roles = selectedRoles.Roles;
string[] role = roles.Split(',');
int countTags = role.Count();
foreach (string word in role)
{
CheckBoxList1.SelectedValue = word;
Response.Write(word + "<br/>");
countTags -= 1;
}
}
これが働いた:
var selectedRoles = (from r in DataContext.Context.Core_PagesPermission where r.PageName.Contains(pageName) select r)
.FirstOrDefault();
dsRoles.DataBind();
CheckBoxList1.DataBind();
if(selectedRoles != null)
{
string roles = selectedRoles.Roles;
string[] role = roles.Split(',');
foreach (string word in role)
{
try
{
CheckBoxList1.Items.FindByValue(word).Selected = true;
}
catch (Exception exp)
{
lbError.Text= exp.ToString();
}
あなたがあなたの質問をより正確にしてください可能性があります。私は前提を正しく守っています:あなたはすべての権限を表示するチェックボックスリストを持っていて、その権限をDBでチェックしたいのですか? –
はい私の純粋な英語のために申し訳ありません –