Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 20th, 2005, 04:36 AM
Authorized User
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.Net Datagrid:-My Code is not working

Hi all,

           Can, give me some idea to Build the customise datagrid control. My code is not working properly.
 My code is given below:----

 Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles DataGrid1.EditCommand
            Me.DataGrid1.EditItemIndex = e.Item.ItemIndex
            Me.DataGrid1.DataSource = cls.FillDataSet
        Catch ex As Exception
            CType(e.Item.Cells(0).Controls(0), TextBox).Visible = False

End Try
End Sub

 I have three Field in Product_Id,Product_Name,Price

I Make the column uneditable Which hold the Product_Id information

Old January 21st, 2005, 07:55 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Are you getting an error? If so, what is it?

A better method I have found would look something like this:

CType(e.Item.FindControl("txtProductID"), TextBox).Visible = False

This eliminates the need to know the exact cell and control index.

Old January 22nd, 2005, 01:50 AM
Authorized User
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

Product_Id, Product_Name,Price this three are autogenerated column
Product_Id = cell(3)
When I try to Hide the cell using this code when to click on edit button

CType(e.Item.Cells(3).Controls(0), TextBox).Visible = False

Its throw an error: Index out of Range

But When it Used In UpdateCommad Procedure it working fine

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net 2.0 tutorial not working out so well. dclark ASP.NET 2.0 Basics 1 July 16th, 2006 07:11 PM
working with CMS from ASP.NET naidukap ASP.NET 1.0 and 1.1 Professional 0 April 2nd, 2006 05:38 AM
ASP.Net not working astronaut_10 ASP.NET 1.0 and 1.1 Basics 1 August 27th, 2004 02:50 AM
C# code not working with ASP.NET socoolbrewster ASP.NET 1.0 and 1.1 Basics 6 August 25th, 2003 09:54 AM

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