Wrox Programmer Forums
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 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 October 24th, 2004, 12:13 AM
shs shs is offline
Authorized User
Join Date: Mar 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Editing Datagrid with hyperlink column

I have a datagrid to edit. when I make one of the columns in the datagrid hyperlinked I can not edit it anymore and I get error msg. here is my code:

Sub MyGrid_Update(sender As Object, e As DataGridCommandEventArgs)

Dim strCompId as Integer = e.Item.Cells(1).Text
Dim strCompName as String = CType(e.Item.Cells(2).Controls(0), TextBox).Text

Dim strSQL as String = "UPDATE [company] SET [comp_name] = @comp_name where [comp_id] = @comp_id"

.....opening the connection...

 Dim parameterName as OleDbParameter = new OleDbParameter("@comp_name", OleDbType.VarWChar, 50)
        parameterName.Value = strCompName
   Dim parameterIdno as OleDbParameter = new OleDbParameter("@comp_id", OleDbType.Integer)
        parameterIdno.Value = strCompId

        MyGrid.EditItemIndex = -1
End Sub
here is the grid:
                                <asp:EditCommandColumn EditText=" Edit " ButtonType="PushButton"
    UpdateText="Update" CancelText="Cancel" />

HeaderText="ID" DataNavigateUrlField="comp_id"

the code works fine when I use
<asp:BoundColumn HeaderText="ID" DataField="comp_id" ReadOnly="true"/>
instead of above hyperlinkcolumn
(I just want to update the company name)

<asp:BoundColumn HeaderText="Company Name" DataField="comp_name"
    ItemStyle-HorizontalAlign="Left" />

here is the error:

 Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 65: Sub MyGrid_Update(sender As Object, e As DataGridCommandEventArgs)
Line 66:
Line 67: Dim strCompId as Integer = e.Item.Cells(1).Text
Line 68: Dim strCompName as String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Line 69: Dim strCom


Similar Threads
Thread Thread Starter Forum Replies Last Post
Doubts on DataGrid Hyperlink Column saravananedu ASP.NET 2.0 Basics 0 April 3rd, 2007 08:37 AM
Datagrid Button/Hyperlink Column snowydust VB How-To 0 September 6th, 2004 02:14 AM
DataGrid hyperlink column error burdickdave ASP.NET 1.x and 2.0 Application Design 3 February 26th, 2004 03:41 PM

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