Hi there,
I have a asp:RadioButtonList inside a Repeater and it is working fine except that they are not grouping. I tried GroupName and nothing happens.
Here's my back end code:
void Question(){
OleDbDataAdapter objDAque;
OleDbDataAdapter objDAopt;
DataSet objDS = new DataSet(); // create a recordset empty
objConn.Open();
objDAque = new OleDbDataAdapter("SELECT * FROM simulado_question", objConn); //execute the query
objDAque.Fill(objDS, "question");
objDAopt = new OleDbDataAdapter("SELECT * FROM simulado_option", objConn);
objDAopt.Fill(objDS, "option");
DataRelation rel = new DataRelation("joinQueOpt", objDS.Tables["question"].Columns["id_ques"] , objDS.Tables["option"].Columns["id_ques"]);
objDS.Relations.Add(rel);
dlQues.DataSource = objDS.Tables["question"].DefaultView;
dlQues.DataBind();
objConn.Close();
}
void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
((Repeater)e.Item.FindControl("dlOption")).DataSource=((DataRowView)e.Item.DataItem).CreateChildView("joinQueOpt");
((Repeater)e.Item.FindControl("dlOption")).DataBind();
}
}
And the Controlers:
<asp:Repeater ID="dlQues" runat="server" OnItemDataBound="R1_ItemDataBound" >
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "question")%>
<asp:Repeater ID="dlOption" runat="server" >
<itemtemplate>
<asp:RadioButtonList ID="rblOption" Runat="server" DataTextField="option" DataValueField="id_opt"/>
</itemtemplate>
</asp:Repeater>
</itemtemplate>
</asp:Repeater>
Anyone can help?
Thanks...
I have a asp:RadioButtonList inside a Repeater and it is working fine except that they are not grouping. I tried GroupName and nothing happens.
Here's my back end code:
void Question(){
OleDbDataAdapter objDAque;
OleDbDataAdapter objDAopt;
DataSet objDS = new DataSet(); // create a recordset empty
objConn.Open();
objDAque = new OleDbDataAdapter("SELECT * FROM simulado_question", objConn); //execute the query
objDAque.Fill(objDS, "question");
objDAopt = new OleDbDataAdapter("SELECT * FROM simulado_option", objConn);
objDAopt.Fill(objDS, "option");
DataRelation rel = new DataRelation("joinQueOpt", objDS.Tables["question"].Columns["id_ques"] , objDS.Tables["option"].Columns["id_ques"]);
objDS.Relations.Add(rel);
dlQues.DataSource = objDS.Tables["question"].DefaultView;
dlQues.DataBind();
objConn.Close();
}
void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
((Repeater)e.Item.FindControl("dlOption")).DataSource=((DataRowView)e.Item.DataItem).CreateChildView("joinQueOpt");
((Repeater)e.Item.FindControl("dlOption")).DataBind();
}
}
And the Controlers:
<asp:Repeater ID="dlQues" runat="server" OnItemDataBound="R1_ItemDataBound" >
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "question")%>
<asp:Repeater ID="dlOption" runat="server" >
<itemtemplate>
<asp:RadioButtonList ID="rblOption" Runat="server" DataTextField="option" DataValueField="id_opt"/>
</itemtemplate>
</asp:Repeater>
</itemtemplate>
</asp:Repeater>
Anyone can help?
Thanks...
Last edited: