2011-05-28 29 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