Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 December 19th, 2006, 05:54 PM
Authorized User
 
Join Date: Mar 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing a Cell in a Webform Datagrid

For the life of me I cant figure out why using this code:
Code:
 Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
        Label1.Text = DataGrid1.SelectedItem.Cells(7).Text

    End Sub
produces this error:

Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index]
   System.Web.UI.ControlCollection.get_Item(Int32 index) +58
   System.Web.UI.WebControls.TableCellCollection.get_ Item(Int32 index) +22
   DR.WebForm1.DataGrid1_SelectedIndexChanged(Object sender, EventArgs e) in Z:\Inetpub\wwwroot\New Intranet\Medecine\DR\WebForm1.aspx.vb:170
   System.Web.UI.WebControls.BaseDataList.OnSelectedI ndexChanged(EventArgs e) +108
   System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source, EventArgs e) +159
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
   System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source, EventArgs e) +100
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
   System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +120
   System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +138
   System.Web.UI.Page.ProcessRequestMain() +1292



This datagrid is bound to a stored procedure filled dataset at runtime. I have tried to get data out of every cell in the grid, and only cell(0)( the select Button) does not .....never mind .....

 
Old December 28th, 2006, 01:14 AM
Registered User
 
Join Date: Dec 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 CType(e.Item.Cells(0).FindControl("txtUpdPassword" ), TextBox)


use this , this might help u







Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a cell in a DataGridView Martin Woodhouse C# 2008 aka C# 3.0 12 October 3rd, 2008 08:42 AM
Accessing one cell from gridview Aker C# 1 May 22nd, 2008 03:13 PM
How to retrive a value from DataGrid (WebForm) jkusmanto VB.NET 2002/2003 Basics 0 June 13th, 2006 02:47 AM
How to Send SMS to cell phone from asp.net webform somissac General .NET 1 March 12th, 2005 01:32 AM
Cannot display datagrid on ASP webform smujib Classic ASP Basics 6 March 11th, 2005 09:12 AM





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