|
-
Oct 11th, 2005, 09:10 AM
#1
Thread Starter
Member
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:
Dim cSQConnection As SqlConnection
Dim cSqlCommand As SqlCommand
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Sub BindData()
cSQConnection = New SqlConnection("server=MySQLServer;database=MyDatabase;")
cSQConnection.Open()
cSqlCommand = New SqlCommand("SELECT * FROM Projects", cSQConnection)
DataGrid1.DataSource = cSqlCommand.ExecuteReader()
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
BindData()
End Sub
-
Oct 11th, 2005, 12:02 PM
#2
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)
-
Oct 11th, 2005, 12:39 PM
#3
Thread Starter
Member
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">
<asp ataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 72px; POSITION: absolute; TOP: 72px" runat="server"
Width="472px" Height="184px"></asp ataGrid>
</form>
</body>
</HTML>
-
Oct 11th, 2005, 12:51 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|