2011-05-28 31 views
1

我创建了一个带单选按钮列表的gridview。它抛出像带单选按钮列表模板字段的gridview

RadioButtonList2' has a SelectedValue which is invalid because it does not exist in the list of items. 
Parameter name: value 

而这个错误是我的编码,在gridview

q = "SELECT 
     s.rollno, 
     s.studname, 
     d.deptname, 
     ct.ctype, 
     c.course, 
     s.status 
    FROM 
     dbmasdeptcreat d, 
     dbmascoursetypecreat ct, 
     dbmascoursecreat c, 
     dbmasstuddet s 
    WHERE 
     s.deptid=d.deptid AND 
     s.ctypeid=ct.ctypeid AND 
     s.cid=c.cid AND 
     s.status <> 'ACTIVE' AND 
     s.collname='" & lablcollname.Text & "'" 

     ds = c1.getDataset(q) 
     GridView2.DataSource = ds 
     GridView2.DataBind() 
     GridView2.Visible = True 

结合,这是我的GridView的信源编码

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None"> 
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> 
    <Columns> 
     <asp:CommandField HeaderText="Edit" ShowEditButton="True" ShowHeader="True" /> 
     <asp:BoundField DataField="rollno" HeaderText="Rollno" ReadOnly="True" /> 
     <asp:BoundField DataField="studname" HeaderText="Student Name" ReadOnly="True" /> 
     <asp:BoundField DataField="deptname" HeaderText="Department " ReadOnly="True" /> 
     <asp:BoundField DataField="course" HeaderText="Course Type" ReadOnly="True" /> 
     <asp:BoundField DataField="course" HeaderText="Course" ReadOnly="True" /> 
     <asp:TemplateField HeaderText="Status"> 
      <EditItemTemplate> 
       <asp:RadioButtonList ID="RadioButtonList2" runat="server" Text='<%# Bind("status") %>' > 
        <asp:ListItem>GUEST</asp:ListItem> 
        <asp:ListItem>REGULAR</asp:ListItem> 
       </asp:RadioButtonList> 
      </EditItemTemplate> 
      <ItemTemplate> 
       <asp:Label ID="Label1" runat="server" Text='<%# Eval("status") %>'></asp:Label> 
      </ItemTemplate> 
     </asp:TemplateField> 
    </Columns> 
    <EditRowStyle BackColor="#999999" /> 
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> 
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> 
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> 
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> 
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> 
    <SortedAscendingCellStyle BackColor="#E9E7E2" /> 
    <SortedAscendingHeaderStyle BackColor="#506C8C" /> 
    <SortedDescendingCellStyle BackColor="#FFFDF8" /> 
    <SortedDescendingHeaderStyle BackColor="#6F8DAE" /> 
</asp:GridView> 
+0

您可能需要添加更多标签,以便我们知道您正在使用哪种语言或系统。 – Ben 2011-05-28 12:04:33

+0

你知道你的查询容易受到sql注入吗? – 2011-11-20 21:39:23

回答

0

我想你没有你的连接代码是否正确,请重新附加,并且是否使用某种数据源(如SQL数据源)填充单选按钮列表?因为这种错误通常发生在从数据源中的值不匹配,如果你的单选按钮,列表和数据定义如下

Apple 
Orange 
Banana 

值,你的单选按钮列表定义例如值的集合中的任何值源正在返回芒果然后单选按钮列表将抛出这种错误,因为它不能选择芒果作为其定义的集合中不可用。

如果您提供的代码,我可以帮助你更好。

+0

谢谢你的回复..我有更新我的错误请检查.... – kuppu 2011-05-28 12:18:20