错误描述:
索引超出范围。必须为非负值并小于集合大小。参数名: index 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 
异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。参数名: index程序部分代码:
界面:[/color]<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体" id="FONT1">
<asp:TextBox id="nameTB" style="Z-INDEX: 101; LEFT: 224px; POSITION: absolute; TOP: 80px" runat="server"
Width="192px"></asp:TextBox>
<TABLE id="Table2" style="Z-INDEX: 109; LEFT: 224px; WIDTH: 550px; POSITION: absolute; TOP: 208px; HEIGHT: 144px"
cellSpacing="0" cellPadding="0" width="550" border="1">
<TR>
<TD>
<asp:DataList id="imgDL" runat="server" Width="544px" BorderColor="Blue" HorizontalAlign="Center"
RepeatDirection="Horizontal" RepeatColumns="4" EditItemIndex="1">
<SelectedItemStyle HorizontalAlign="Center"></SelectedItemStyle>
<HeaderTemplate>
<asp:Button id="loginBN" runat="server" CommandName="tijiao" Text="提 交"></asp:Button>&nbsp;
<asp:Button id="cancelBN" runat="server" CommandName="reset" Text="重 置" CausesValidation="False"></asp:Button>
</HeaderTemplate>
<EditItemStyle HorizontalAlign="Center"></EditItemStyle>
<AlternatingItemStyle HorizontalAlign="Center"></AlternatingItemStyle>
<SeparatorStyle HorizontalAlign="Center"></SeparatorStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<TABLE id="Table1" style="WIDTH: 90px; HEIGHT: 34px" cellSpacing="0" cellPadding="0" width="90"
border="0">
<TR>
<TD align="center"><IMG alt="" src='<%# "userImg.aspx?id="+DataBinder.Eval(Container,"DataItem.id")%>'></TD>
</TR>
<TR>
<TD align="center">
<asp:RadioButton id=imgRB runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title") %>' GroupName="img">
</asp:RadioButton>&nbsp;</TD>
</TR>
</TABLE>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
</asp:DataList></TD>
</TR>
</TABLE>
<asp:TextBox id="mailTB" style="Z-INDEX: 102; LEFT: 224px; POSITION: absolute; TOP: 160px" runat="server"
Width="216px"></asp:TextBox>
<asp:TextBox id="qqTB" style="Z-INDEX: 103; LEFT: 224px; POSITION: absolute; TOP: 120px" runat="server"></asp:TextBox>
<asp:Label id="mailLab" style="Z-INDEX: 104; LEFT: 168px; POSITION: absolute; TOP: 160px" runat="server">E-mail:</asp:Label>
<asp:Label id="qqLab" style="Z-INDEX: 105; LEFT: 200px; POSITION: absolute; TOP: 120px" runat="server">QQ:</asp:Label>
<asp:Label id="nameLab" style="Z-INDEX: 106; LEFT: 184px; POSITION: absolute; TOP: 80px" runat="server">姓名:</asp:Label>
<asp:Label id="Label4" style="Z-INDEX: 107; LEFT: 256px; POSITION: absolute; TOP: 32px" runat="server">用户注册</asp:Label>
<asp:Label id="Label1" style="Z-INDEX: 108; LEFT: 184px; POSITION: absolute; TOP: 208px" runat="server">头像:</asp:Label></FONT>
</form>
</body>//页面加载时执行
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
this.Bind();
}
verdictRB();
}
//数据绑定
private void Bind()
{
OleDbConnection oConn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath("Blog.mdb"));
OleDbDataAdapter oDap = new OleDbDataAdapter("select * from userImg", oConn);
DataSet ds = new DataSet();
oConn.Open();
oDap.Fill(ds, "img");
imgDL.DataSource = ds.Tables["img"];
imgDL.DataKeyField = "id";
imgDL.DataBind();
oConn.Close();
}//Item事件, 主撒就是按钮提交
private void imgDL_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{

switch(e.CommandName)
{
case "tijiao":
{
foreach(DataListItem dLi in this.imgDL.Items)
{
RadioButton Rbn = (RadioButton)dLi.FindControl("imgRB");
if(Rbn.Checked == true)
{
int key = (int)imgDL.DataKeys[e.Item.ItemIndex-1]; Response.Write(key);          //用于测试
}
}
break;
}
case "reset":
{
break;
}
}
}
[color=#FF0000]问题补充:
1.我的大体意思就是:用DataList模板列创建了一个2行4列的图片列表,每个图片下面有个RadioButton控件(image控件RadioButton控件都在模板ItemTemplate里面),使得用户通过RadioButton来选择图片,获得其对应的id值,进而存进数据库。
2.我的提交和重置按钮是放在DataList的HeaderTemplate里面的。
3.所报的错误如上,请大家帮忙看看,给小弟点指导,谢谢!