问题
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
回答1:
I think you could use the repeater control to do that..
MSDN link to repeater page original link
回答2:
Using Repeater contorl over GridView Will give you more control over formating your output.
回答3:
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();
}
};
来源:https://stackoverflow.com/questions/5509765/display-data-in-gridview