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 May 25th, 2005, 08:57 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to pass datagrid record number instead of clic

I got a datagrid that supposed to edit the datagrid once the user clicks on edit button next to each record. I want this page recives the record number as passed value but i do not know how to do it .(datagridupdate?record=4)
Is there a way to pass record value to this part of code which is resposible for finding the record that we want to update ? I be happy to get some help here. thanks
Code:
    Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
        DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
        DataBindGrid
    End Sub

Code:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script language="VB" runat="server">
    Dim objConnection As SqlConnection
    Dim myDataReader As SqlDataReader    

    Sub Page_Load(Sender As Object, E As EventArgs) 
        ' Set up our connection.
        objConnection = New SqlConnection("Data Source=(local);" _
            & "Initial Catalog=teniss2;User Id=web;Password=web;" _
            & "Connect Timeout=15;Network Library=dbmssocn;")

        LoadDataFromDB

        If Not IsPostBack Then
            DataBindGrid
        End If
    End Sub

    Sub LoadDataFromDB()
        Dim objCommand As SqlCommand

        ' Create new command object passing it our SQL query
        ' and telling it which connection to use.
        objCommand = New SqlCommand("SELECT * FROM Players;", objConnection)

        ' Open the connection, execute the command, and close the connection.
        objConnection.Open()
        myDataReader = objCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
    End Sub

    Sub DataBindGrid()
        DBEditDataGrid.DataSource = myDataReader
        DBEditDataGrid.DataBind
    End Sub

    Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
        DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
        DataBindGrid
    End Sub

.......
.......
 
Old May 25th, 2005, 01:17 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I think you need to call LoadDataFromDB()
 first then
DataBindGrid()

 
Old May 25th, 2005, 01:22 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by jbenson001
 I think you need to call LoadDataFromDB()
first then
DataBindGrid()

lol .that was toooooo general!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Current Record Number Base VB How-To 1 December 7th, 2005 05:26 PM
Record number in Access Report Niaz Access 4 July 19th, 2005 01:48 PM
record number maximum Jorge SQL Server 2000 3 December 3rd, 2004 12:00 PM
variable number of fields in record manisha.anand Oracle 0 July 1st, 2004 05:00 PM
show the record number yami56 Access 9 April 5th, 2004 08:35 PM





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