Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 14th, 2008, 02:46 PM
Friend of Wrox
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default error with RowDataBound but not with RowCreated


Can someone explain me why the same code with the event
GridView1_RowDataBound gives this error:

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

and not with the event GridView1_RowCreated ?

In normal mode, everything is shown correcly, but when i click on the Edit button in the gridview, the error happens.


Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
        If (e.Row.RowState And DataControlRowState.Edit) =
DataControlRowState.Edit Then
            If e.Row.RowType = DataControlRowType.DataRow Then
                Dim dd As DropDownList
                Dim i As Integer
                Dim z As ListItem
                dd = e.Row.FindControl("DropDownList1")
                For i = 1 To 20
                    z = New ListItem(i, i)
            End If
        End If
End Sub

aspx file:
 <asp:DropDownList ID="DropDownList1" runat="server" Width="90px" SelectedValue='<%# Bind("wa") %>' >
 <asp:Label ID="Label2" runat="server" Text='<%# Bind("wa") %'> </asp:Label>

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
Gridview Alt rows not using RowDataBound logic pbranumfl ASP.NET 2.0 Basics 5 March 22nd, 2007 05:28 PM
Phile Page error, visual studio error reps BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 27th, 2003 10:11 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.