在Aspxdataview中设置RadioButtonList的选定索引:Devexpress Asp.net

时间:2016-04-18 07:43:37

标签: asp.net devexpress radiobuttonlist dataview

问题

我无法在数据视图内的radiobuttonlist中设置所选索引。我在Dataview的数据绑定事件中绑定了radiobuttonlist。

问题

“下方”行用于设置所选索引。在每个dataview项中将所选索引设置为0。我在dataview中显示三个项目。

 aspxrdOptions.Items.FindByText(optionText).Selected = true;

代码

protected void ASPxDataView1_DataBound(object sender, EventArgs e)

  {

        foreach (DataViewItem item in ASPxDataView1.Items)
        {
            ASPxRadioButtonList aspxrdOptions = (ASPxRadioButtonList)ASPxDataView1.FindItemControl("ASPxRadioButtonList1", item);
            DataViewItemTemplateContainer container = aspxrdOptions.NamingContainer as DataViewItemTemplateContainer;
            int QuestionID = Convert.ToInt32(container.EvalDataItem("question_Id"));             
            DataTable dt = (DataTable)ViewState["Optionkey"];
            DataView dv = dt.DefaultView;
            dv.RowFilter = "question_Id =" + QuestionID;
            dv.Sort = "OptionSequence ASC";
            aspxrdOptions.DataSource = dv.ToTable();
            aspxrdOptions.DataBind();


            string optionText = getOptionTextByQuestionId(QuestionID);

            if (optionText != "-1" && optionText != "")
            {
             aspxrdOptions.Items.FindByText(optionText).Selected = true;
            }


        }
 }

0 个答案:

没有答案