0

我有问题我尝试使用 linq 加入 listItem(checkboxItem) 和 DataSet Row 以在 Selected 中制作 listItem(checkboxItem)

private void BindCheckboxList()
{
    int resID = Convert.ToInt32(hf_resID.Value);
    DataSet skillDS = Skill.GetSkillsForResousrce(resID);


    //checked pre selected items 
    var query = from ListItem li in chblSkills.Items
                join dsRow in skillDS.Tables[0].Rows
                on li.Value equals ds
                select ListItem;

    foreach (ListItem li in query)
        ListItem.selected = true;
}
4

1 回答 1

0

I think you want something like this:

    var query = from ListItem li in chblSkills.Items
            from dsRow in skillDS.Tables[0].Rows
            where li.Value == dsRow["ColumnName"]
            select ListItem

Your 'where' need to be an expression eligible to an 'if' statement.

于 2013-04-26T16:47:57.897 回答