我的 ASP.net 网络表单中有很多单选按钮列表。我使用如下所示的方法动态绑定它们:
public static void PopulateRadioButtonList(DataTable currentDt, RadioButtonList currentRadioButtonList, string strTxtField, string txtValueField,
string txtDisplay)
{
currentRadioButtonList.Items.Clear();
ListItem item = new ListItem();
currentRadioButtonList.Items.Add(item);
if (currentDt.Rows.Count > 0)
{
currentRadioButtonList.DataSource = currentDt;
currentRadioButtonList.DataTextField = strTxtField;
currentRadioButtonList.DataValueField = txtValueField;
currentRadioButtonList.DataBind();
}
else
{
currentRadioButtonList.Items.Clear();
}
}
现在,我只想显示 RadioButton 项文本的 DataTextField 的第一个字母。
例如,如果值很好,我只想显示 G。如果它公平,我想显示 F。
我如何在 C# 中执行此操作
谢谢