GridView中的控件的数据绑定的问题

chunmiao3032 2009-01-22 01:21:26
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label24" runat="server" Text="一、单选题(每题"></asp:Label>
<asp:Label ID="Label27" runat="server"></asp:Label>
<asp:Label ID="Label25" runat="server" Text="分)"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<table id="Table2" align="center" border="0" cellpadding="1" cellspacing="1" width="100%">
<tr>
<td colspan="3">
<asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'>
</asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Title","、{0}") %>'>
</asp:Label>
<asp:Label ID="Label3" runat="server" ForeColor="red" Text='<%# Eval("Answer") %>'>
</asp:Label>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("Mark") %>' Visible="false">
</asp:Label>
</td>
</tr>
<tr>
<td width="35%">
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="Sl" Text='<%# Eval("AnswerA") %>' /></td>
<td width="35%">
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="Sl" Text='<%# Eval("AnswerB") %>' /></td>
<td>
</td>
</tr>
<tr>
<td width="35%">
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="Sl" Text='<%# Eval("AnswerC") %>' /></td>
<td width="35%">
<asp:RadioButton ID="RadioButton4" runat="server" GroupName="Sl" Text='<%# Eval("AnswerD") %>' /></td>
<td>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="12pt" HorizontalAlign="Left" />
</asp:GridView>
...全文
70 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wptad 2009-01-22
  • 打赏
  • 举报
回复
行的索引 ,转换一下 ((dataViewRow)Container.DataItem) 看看
wuyq11 2009-01-22
  • 打赏
  • 举报
回复
<%# Container.DataItemIndex+1 %>'> 显示记录行号
wptad 2009-01-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 chunmiao3032 的回复:]
<asp:Label ID="Label1" runat="server" Text=' <%# Container.DataItemIndex+1 %>'>
</asp:Label>


<%# Container.DataItemIndex+1 %>'> 这个是什么意思?
[/Quote]

一般用来标上GridView的序号,这样更加人性化,在你这个例子里应该是输出题号
wptad 2009-01-22
  • 打赏
  • 举报
回复
数据序值加1并输出
HDNGO 2009-01-22
  • 打赏
  • 举报
回复
咋了?
wptad 2009-01-22
  • 打赏
  • 举报
回复
什么问题?
chunmiao3032 2009-01-22
  • 打赏
  • 举报
回复
<asp:Label ID="Label1" runat="server" Text=' <%# Container.DataItemIndex+1 %>'>
</asp:Label>


<%# Container.DataItemIndex+1 %>'> 这个是什么意思?

111,130

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧