C# 在gridview中显示数据
我想在Gridview中以类似于图像的格式显示数据 各位有什么想法吗 表中的数据是这样存储的C# 在gridview中显示数据,c#,asp.net,gridview,C#,Asp.net,Gridview,我想在Gridview中以类似于图像的格式显示数据 各位有什么想法吗 表中的数据是这样存储的 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 i
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
谢谢你我想你可以用中继器控制来实现这一点
到repeater页面在GridView上使用repeatercontorl将使您能够更好地控制输出格式。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>
谢谢你,马格努斯。如果这个问题与林克一起出现?我正在使用vs2005。QuestionEntity只是一个例子,可以是任何东西。例如,如果使用DataTable绑定GridView,则为DataRow。但是,您可以使用IEnumerable Answers属性创建自己的QuestionEntity类,并从Linq查询返回该属性。如果您找到了答案,是否可以将该解决方案作为答案发布?这可能会帮助其他遇到类似问题的人。我没有使用上述模式,我已经改变了一切。。这就是原因
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();
}
};