Reputation: 329
i want to display data in Gridview in a format like in the image.
any ideas folks?
the datas in table is stored in this way
Qsn1 A train running at the speed of 60 km/hr crosses a pole in 9 seconds. What is the length of the train? Option1 150 metres 5
Qsn1 A train running at the speed of 60 km/hr crosses a pole in 9 seconds. What is the length of the train? Option1 152 metres 5
Qsn1 A train running at the speed of 60 km/hr crosses a pole in 9 seconds. What is the length of the train? Option1 154 metres 5
Qsn1 A train running at the speed of 60 km/hr crosses a pole in 9 seconds. What is the length of the train? Option1 155 metres 5
thank you
Upvotes: 2
Views: 984
Reputation: 46919
ASPX
<asp:GridView runat="server" ID="gv1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%# Eval("Question") %>
<asp:RadioButtonList runat="server" ID="rbl1" DataTextField="Name" DataValueField="QuestionID"></asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code
gv1.RowDataBound += (s, ev) =>
{
if (ev.Row.RowType == DataControlRowType.DataRow)
{
var rbl1 = (ListControl)ev.Row.FindControl("rbl1");
rbl1.DataSource = ((QuestionEntity)ev.Row.DataItem).Answers;
rbl1.DataBind();
}
};
Upvotes: 0
Reputation: 13825
I think you could use the repeater control to do that..
MSDN link to repeater page original link
Upvotes: 1
Reputation: 498
Using Repeater contorl over GridView Will give you more control over formating your output.
Upvotes: 0