Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 January 24th, 2005, 01:24 AM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trouble with DataGrid Update [ASP .Net]

Hey all,

I have a problem with the update using a datagrid control in Visual Studio .Net ... here is my code:

Code:
    Private Sub MyDG_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles MyDG.EditCommand

        Me.MyDG.EditItemIndex = e.Item.ItemIndex
        MyDG.DataBind()
        Dim key As String = MyDG.DataKeys(e.Item.ItemIndex).ToString

        Dim catName, CatImage, CatThumb, CatDesc As String
        Dim tb As TextBox

        tb = CType(e.Item.Cells(2).Controls(0), TextBox)
        catName = tb.Text

        tb = CType(e.Item.Cells(3).Controls(0), TextBox)
        CatImage = tb.Text

        tb = CType(e.Item.Cells(4).Controls(0), TextBox)
        CatThumb = tb.Text

        tb = CType(e.Item.Cells(5).Controls(0), TextBox)
        CatDesc = tb.Text

        Dim r As MyDS.CategoriesRow
        r = MyDS1.Categories.FindByCategoryID(key)
        r.CategoryName = catName
        r.CatImage = CatImage
        r.Description = CatDesc
        r.Thumbnail = CatThumb

        SqlDataAdapter1.Update(MyDS1)
        Me.MyDG.EditItemIndex = -1
        MyDG.DataBind()

    End Sub
When i run, i get the following error: Specified argument was out of the range of valid values. Parameter name: index

This line get marked in red:
Line 146: tb = CType(e.Item.Cells(2).Controls(1), TextBox)

It seems a problem with the Controls or the Cells index, but there is no mistake or so i belive. Any help?



Regards,
Hany
 
Old January 24th, 2005, 09:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

When the page loads, is there anything in that cell?

 
Old January 25th, 2005, 12:42 PM
Authorized User
 
Join Date: Sep 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

check for the controlcollection count for cell(2)
and check for the cell index also...

cheers

jais






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET C# - Trouble with checkbox booksnore2 General .NET 1 October 5th, 2004 11:46 PM
trouble shoot XML SQL ASP.net VB fzilz ADO.NET 1 April 7th, 2004 11:29 PM
Chapter 1 ASP.NET Trouble Shooting rragoonanan BOOK: Beginning ASP.NET 1.0 14 December 3rd, 2003 09:53 AM





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