Results 1 to 4 of 4

Thread: DataGrid Edit command problems

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2000
    Location
    Lithuania
    Posts
    36

    DataGrid Edit command problems

    Hi,

    I’m trying to use Datagrid edit feature. When I press Edit button Datagrid shows Update and Cancel buttons, but I still can’t see text boxes. Please take a look at my code and say where is the problem.

    P. S. Sorry for my English



    VB Code:
    1. Dim cSQConnection As SqlConnection
    2.     Dim cSqlCommand As SqlCommand
    3.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         If Not Page.IsPostBack Then
    5.             BindData()
    6.         End If
    7.     End Sub
    8.     Sub BindData()
    9.         cSQConnection = New SqlConnection("server=MySQLServer;database=MyDatabase;")
    10.         cSQConnection.Open()
    11.         cSqlCommand = New SqlCommand("SELECT * FROM Projects", cSQConnection)
    12.         DataGrid1.DataSource = cSqlCommand.ExecuteReader()
    13.         DataGrid1.DataBind()
    14.     End Sub
    15.     Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
    16.         DataGrid1.EditItemIndex = e.Item.ItemIndex
    17.         BindData()
    18.     End Sub
    Fizikas

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: DataGrid Edit command problems

    What does the Datagrid code on the ASPX file look like?
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2000
    Location
    Lithuania
    Posts
    36

    Re: DataGrid Edit command problems

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication3.WebForm1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <aspataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 72px; POSITION: absolute; TOP: 72px" runat="server"
    Width="472px" Height="184px"></aspataGrid>
    </form>
    </body>
    </HTML>
    Fizikas

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: DataGrid Edit command problems

    OK. The reader is not an updatable recordset object, so the code cannot automatically handle the proper updates, etc to the database.

    In reality, it is better for you to handle it anyway.

    Here is a link for you, use the VB examples, not the J#.

    http://samples.gotdotnet.com/quickst...ataaccess.aspx
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width