0

我正在使用RadGridTelerik 的 a 并尝试根据页面上的其他位置切换 aRadioButtonListAutoPostBack属性。CheckBox

<telerik:RadGrid ID="rg" runat="server" Skin="Office2010Silver" GridLines="Both" OnNeedDataSource="rg_NeedDataSource"
                 OnItemDataBound="rg_ItemDataBound">
    <MasterTableView Width="100%" DataKeyNames="StudentID, Response, Tested">
        <Columns>
            <telerik:GridBoundColumn UniqueName="StudentName" HeaderText="Student Name" DataField="StudentName"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="StudentID" HeaderText="Student ID" DataField="StudentID"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Answer" HeaderText="Answer" DataField="Answer"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Response" HeaderText="Score" DataField="Response"></telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Score" ItemStyle-Wrap="false">
                <ItemTemplate>
                    <asp:RadioButtonList ID="rblScore" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal" OnSelectedIndexChanged="rblScore_IndexChanged" AutoPostBack='<%#Eval(chkAutoSave.Checked.ToString()) %>'></asp:RadioButtonList>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

我收到错误:DataBinding: 'System.Data.DataRowView'不包含名称为 的属性True。是否可以这样做,还是我需要在 内这样做ItemDataBound

4

2 回答 2

0

首先给模板列一个ID

 <telerik:GridTemplateColumn HeaderText="Score" ItemStyle-Wrap="false" ID="Score">
                <ItemTemplate>
                    <asp:RadioButtonList ID="rblScore" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal" OnSelectedIndexChanged="rblScore_IndexChanged" AutoPostBack='<%#Eval(chkAutoSave.Checked.ToString()) %>'></asp:RadioButtonList>
                </ItemTemplate>
            </telerik:GridTemplateColumn>

在后面的代码中:

  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
            {
    if (e.Item is GridDataItem)
                            {
    GridDataItem dataBoundItem = e.Item as GridDataItem;
    Bool _boolChecked=Convert.ToBoolean(dataBoundItem["chkAutoSave.Checked"].toString());
              ((RadioButtonList )dataBoundItem["Score"].FindControl("rblScore")).AutoPostBack= _boolChecked;
    }
    }

问候

于 2013-05-17T16:47:46.737 回答
0

我继续使用 ItemDataBound 并且效果很好......但如果有人对此有解决方案,我会很感兴趣。

于 2013-05-17T16:41:34.480 回答