IQueryable with RadioButtonList.SelectedValue

本文关键字:SelectedValue RadioButtonList with IQueryable | 更新日期: 2023-09-27 18:26:18

我可以使用IQueryableRadioButtonList中的选定值来从表中获取选定值吗?

我有RadioButtonListDataValueField="Code"

我的代码是

public IQueryable<Tbl_name> GetValuesfromTable()
{
    return dbo.Tbl_name.Where(q => q.Code = (RadioButtonList.SelectedItem.Value)).OrderBy(c => c.Date_publication);
}

你能帮我查询一下吗?

IQueryable with RadioButtonList.SelectedValue

如果您想从该表中获取单个值。我正在考虑将Code序列化为int:

public IQueryable<Tbl_name> GetValuesfromTable()
{
    var selectedCode = Convert.ToInt32(RadioButtonList.SelectedValue);
    return dbo.Tbl_name.Where(q => q.Code == selectedCode)
        .OrderBy(c => c.Date_publication);
}