开发者

display data in gridview

开发者 https://www.devze.com 2023-02-21 21:45 出处:网络
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

i want to display data in Gridview in a format like in the image.

any ideas folks?

display data in gridview

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


I think you could use the repeater control to do that..

MSDN link to repeater page original link


Using Repeater contorl over GridView Will give you more control over formating your output.


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();
                        }
                    };
0

精彩评论

暂无评论...
验证码 换一张
取 消