我有一个GridView控件,其中包含一个包含数据绑定RadioButtonList的列。 RBL正确绑定到其DataTable,但没有显示在GridView中。在标记中添加ListItems确实显示,并显示Label控件 - 我只是将这两个做为测试。有没有人看到我失踪?数据绑定RadioButtonList绑定,但现在显示在GridView中
TIA任何帮助。 迈克
标记:
<asp:TemplateField HeaderText="Preset Text" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:RadioButtonList ID="rblPresetText" runat="server" DataValueField="pKey" DataTextField="Contents" GroupName="PresetText" RepeatDirection="Vertical"></asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
代码隐藏:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
GlobalVar.LoadData(Session("UserPKey"))
Header1.ConnectionStr = GlobalVar.ConnectString
Header1.HDLawFirm = GlobalVar.LawFirmDir
If Page.IsPostBack = False Then
FillNotesDataSet()
BindNotesGrid()
BindPresetTextRadioButtonList()
End If
End Sub
Protected Sub BindPresetTextRadioButtonList()
Dim DAL As New DataAccessLayer
Dim dtPresetText As New DataTable
Dim rblPresetText As New RadioButtonList
dtPresetText = DAL.GetTextPickerTextForUser(Session("ClientKey"), Session("UserPKey"))
rblPresetText.DataSource = dtPresetText
rblPresetText.DataBind()
End Sub
是否检查'dtPresetText'是不是空的? – Andrei
是的,它有13行,我甚至可以在绑定后立即从DDL中获取值。 – Mike