I have been working for quite some time on this issue which in theory
should be quite simple. The problem is that the Cancel and Save
events are not fired when their respective buttons are clicked.
I have read several posts which say to put your column generating
section in the Page_Init section and it will solve the
problem....however, it hasn't solved mine.
Can somebody please take a look at this and provide any insight if
possible?
Thanks,
Mark
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class DynaGrid
Inherits System.Web.UI.Page
Protected WithEvents plcData As
System.Web.UI.WebControls.PlaceHolder
Protected WithEvents dgData As New
System.Web.UI.WebControls.DataGrid()
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
BindData()
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub
Sub BindData()
Dim dbConn As New OleDbConnection()
dbConn.ConnectionString =
"provider=sqloledb;Server=SERVERNAME;Database=User ;UID=USERID;PWD=PASSWORD"
Dim oAdapter As New OleDbDataAdapter("SELECT * FROM T_Group ",
dbConn)
Dim dsData As New DataSet()
oAdapter.Fill(dsData)
dgData.AllowPaging = False
dgData.AllowSorting = False
dgData.AutoGenerateColumns = False
'dgData.EnableViewState = False
Dim x As Integer
For x = 0 To dsData.Tables(0).Columns.Count - 1
Dim bcCol As New BoundColumn()
bcCol.HeaderText = dsData.Tables(0).Columns(x).ColumnName
bcCol.DataField = dsData.Tables(0).Columns(x).Caption
dgData.Columns.Add(bcCol)
bcCol = Nothing
Next
Dim bcEdit As New EditCommandColumn()
bcEdit.ButtonType = ButtonColumnType.PushButton
bcEdit.EditText = "Edit"
bcEdit.CancelText = "Cancel"
bcEdit.UpdateText = "Save"
dgData.Columns.Add(bcEdit)
bcEdit = Nothing
dgData.DataSource = dsData.Tables(0)
dgData.DataBind()
AddHandler dgData.CancelCommand, AddressOf dgData_cmdCancel
AddHandler dgData.EditCommand, AddressOf dgData_cmdEdit
plcData.Controls.Add(dgData)
End Sub
Sub dgData_cmdSave(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
dgData.EditItemIndex = -1
Response.Write(e.CommandName)
dgData.DataBind()
End Sub
Sub dgData_cmdCancel(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
dgData.EditItemIndex = -1
Response.Write(e.CommandName)
dgData.DataBind()
End Sub
Sub dgData_cmdEdit(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
dgData.EditItemIndex = CInt(e.Item.ItemIndex)
Response.Write(e.CommandName)
dgData.DataBind()
End Sub
End Class 6 4468
Mark,
Make sure that viewstate is on and that the grid is recreated every page
load.
If these two things are done it should be working.
If you'd like me to take a look at the code post it and I'll see if I can
get it to work.
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Mark" <ma**********@yahoo.com> wrote in message
news:39**************************@posting.google.c om... I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are clicked.
I have read several posts which say to put your column generating section in the Page_Init section and it will solve the problem....however, it hasn't solved mine.
Can somebody please take a look at this and provide any insight if possible?
Thanks, Mark
Imports System Imports System.Data Imports System.Data.OleDb
Public Class DynaGrid
Inherits System.Web.UI.Page Protected WithEvents plcData As System.Web.UI.WebControls.PlaceHolder Protected WithEvents dgData As New System.Web.UI.WebControls.DataGrid()
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. BindData() InitializeComponent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Sub BindData() Dim dbConn As New OleDbConnection() dbConn.ConnectionString =
"provider=sqloledb;Server=SERVERNAME;Database=User ;UID=USERID;PWD=PASSWORD" Dim oAdapter As New OleDbDataAdapter("SELECT * FROM T_Group ", dbConn) Dim dsData As New DataSet() oAdapter.Fill(dsData)
dgData.AllowPaging = False dgData.AllowSorting = False dgData.AutoGenerateColumns = False 'dgData.EnableViewState = False
Dim x As Integer For x = 0 To dsData.Tables(0).Columns.Count - 1 Dim bcCol As New BoundColumn() bcCol.HeaderText = dsData.Tables(0).Columns(x).ColumnName bcCol.DataField = dsData.Tables(0).Columns(x).Caption dgData.Columns.Add(bcCol) bcCol = Nothing Next
Dim bcEdit As New EditCommandColumn() bcEdit.ButtonType = ButtonColumnType.PushButton bcEdit.EditText = "Edit" bcEdit.CancelText = "Cancel" bcEdit.UpdateText = "Save" dgData.Columns.Add(bcEdit) bcEdit = Nothing
dgData.DataSource = dsData.Tables(0) dgData.DataBind()
AddHandler dgData.CancelCommand, AddressOf dgData_cmdCancel AddHandler dgData.EditCommand, AddressOf dgData_cmdEdit
plcData.Controls.Add(dgData) End Sub
Sub dgData_cmdSave(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = -1 Response.Write(e.CommandName) dgData.DataBind() End Sub
Sub dgData_cmdCancel(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = -1 Response.Write(e.CommandName) dgData.DataBind() End Sub
Sub dgData_cmdEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = CInt(e.Item.ItemIndex) Response.Write(e.CommandName) dgData.DataBind() End Sub End Class
I did post the code.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Mark,
Make sure that viewstate is on and that the grid is recreated every page load.
If these two things are done it should be working.
If you'd like me to take a look at the code post it and I'll see if I can get it to work.
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche "Mark" <ma**********@yahoo.com> wrote in message news:39**************************@posting.google.c om... I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are clicked.
I have read several posts which say to put your column generating section in the Page_Init section and it will solve the problem....however, it hasn't solved mine.
Can somebody please take a look at this and provide any insight if possible?
Thanks, Mark
Imports System Imports System.Data Imports System.Data.OleDb
Public Class DynaGrid
Inherits System.Web.UI.Page Protected WithEvents plcData As System.Web.UI.WebControls.PlaceHolder Protected WithEvents dgData As New System.Web.UI.WebControls.DataGrid()
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. BindData() InitializeComponent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Sub BindData() Dim dbConn As New OleDbConnection() dbConn.ConnectionString =
"provider=sqloledb;Server=SERVERNAME;Database=User ;UID=USERID;PWD=PASSWORD" Dim oAdapter As New OleDbDataAdapter("SELECT * FROM T_Group ", dbConn) Dim dsData As New DataSet() oAdapter.Fill(dsData)
dgData.AllowPaging = False dgData.AllowSorting = False dgData.AutoGenerateColumns = False 'dgData.EnableViewState = False
Dim x As Integer For x = 0 To dsData.Tables(0).Columns.Count - 1 Dim bcCol As New BoundColumn() bcCol.HeaderText = dsData.Tables(0).Columns(x).ColumnName bcCol.DataField = dsData.Tables(0).Columns(x).Caption dgData.Columns.Add(bcCol) bcCol = Nothing Next
Dim bcEdit As New EditCommandColumn() bcEdit.ButtonType = ButtonColumnType.PushButton bcEdit.EditText = "Edit" bcEdit.CancelText = "Cancel" bcEdit.UpdateText = "Save" dgData.Columns.Add(bcEdit) bcEdit = Nothing
dgData.DataSource = dsData.Tables(0) dgData.DataBind()
AddHandler dgData.CancelCommand, AddressOf dgData_cmdCancel AddHandler dgData.EditCommand, AddressOf dgData_cmdEdit
plcData.Controls.Add(dgData) End Sub
Sub dgData_cmdSave(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = -1 Response.Write(e.CommandName) dgData.DataBind() End Sub
Sub dgData_cmdCancel(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = -1 Response.Write(e.CommandName) dgData.DataBind() End Sub
Sub dgData_cmdEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = CInt(e.Item.ItemIndex) Response.Write(e.CommandName) dgData.DataBind() End Sub End Class
Mark,
Sorry I just wasn't specific. I'll chalk up my lack of presenting a logical
request to the amount of sleep I had at the time. :)
Could you please also post the designer's code. Then I can recreate the
entire page and take a look.
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Mark" <ma**********@yahoo.com> wrote in message
news:ul**************@TK2MSFTNGP11.phx.gbl... I did post the code.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Mark,
Make sure that viewstate is on and that the grid is recreated every page load.
If these two things are done it should be working.
If you'd like me to take a look at the code post it and I'll see if I
can get it to work.
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche "Mark" <ma**********@yahoo.com> wrote in message news:39**************************@posting.google.c om... I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are clicked.
I have read several posts which say to put your column generating section in the Page_Init section and it will solve the problem....however, it hasn't solved mine.
Can somebody please take a look at this and provide any insight if possible?
Thanks, Mark
Imports System Imports System.Data Imports System.Data.OleDb
Public Class DynaGrid
Inherits System.Web.UI.Page Protected WithEvents plcData As System.Web.UI.WebControls.PlaceHolder Protected WithEvents dgData As New System.Web.UI.WebControls.DataGrid()
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. BindData() InitializeComponent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Sub BindData() Dim dbConn As New OleDbConnection() dbConn.ConnectionString =
"provider=sqloledb;Server=SERVERNAME;Database=User ;UID=USERID;PWD=PASSWORD" Dim oAdapter As New OleDbDataAdapter("SELECT * FROM T_Group ", dbConn) Dim dsData As New DataSet() oAdapter.Fill(dsData)
dgData.AllowPaging = False dgData.AllowSorting = False dgData.AutoGenerateColumns = False 'dgData.EnableViewState = False
Dim x As Integer For x = 0 To dsData.Tables(0).Columns.Count - 1 Dim bcCol As New BoundColumn() bcCol.HeaderText = dsData.Tables(0).Columns(x).ColumnName bcCol.DataField = dsData.Tables(0).Columns(x).Caption dgData.Columns.Add(bcCol) bcCol = Nothing Next
Dim bcEdit As New EditCommandColumn() bcEdit.ButtonType = ButtonColumnType.PushButton bcEdit.EditText = "Edit" bcEdit.CancelText = "Cancel" bcEdit.UpdateText = "Save" dgData.Columns.Add(bcEdit) bcEdit = Nothing
dgData.DataSource = dsData.Tables(0) dgData.DataBind()
AddHandler dgData.CancelCommand, AddressOf dgData_cmdCancel AddHandler dgData.EditCommand, AddressOf dgData_cmdEdit
plcData.Controls.Add(dgData) End Sub
Sub dgData_cmdSave(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = -1 Response.Write(e.CommandName) dgData.DataBind() End Sub
Sub dgData_cmdCancel(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = -1 Response.Write(e.CommandName) dgData.DataBind() End Sub
Sub dgData_cmdEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) dgData.EditItemIndex = CInt(e.Item.ItemIndex) Response.Write(e.CommandName) dgData.DataBind() End Sub End Class
Justin,
I appreciate you taking a look at this.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DynaGrid.aspx.vb"
Inherits="MMDG.DynaGrid"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>DynaGrid</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<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:PlaceHolder ID="plcData" Runat="server"></asp:PlaceHolder>
</form>
</body>
</HTML>
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uJ**************@TK2MSFTNGP11.phx.gbl... Mark,
Sorry I just wasn't specific. I'll chalk up my lack of presenting a
logical request to the amount of sleep I had at the time. :)
Could you please also post the designer's code. Then I can recreate the entire page and take a look.
Sincerely,
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche "Mark" <ma**********@yahoo.com> wrote in message news:ul**************@TK2MSFTNGP11.phx.gbl... I did post the code.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Mark,
Make sure that viewstate is on and that the grid is recreated every
page load.
If these two things are done it should be working.
If you'd like me to take a look at the code post it and I'll see if I can get it to work.
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche "Mark" <ma**********@yahoo.com> wrote in message news:39**************************@posting.google.c om... > I have been working for quite some time on this issue which in
theory > should be quite simple. The problem is that the Cancel and Save > events are not fired when their respective buttons are clicked. > > I have read several posts which say to put your column generating > section in the Page_Init section and it will solve the > problem....however, it hasn't solved mine. > > Can somebody please take a look at this and provide any insight if > possible? > > Thanks, > Mark > > > > > Imports System > Imports System.Data > Imports System.Data.OleDb > > Public Class DynaGrid > > Inherits System.Web.UI.Page > Protected WithEvents plcData As > System.Web.UI.WebControls.PlaceHolder > Protected WithEvents dgData As New > System.Web.UI.WebControls.DataGrid() > > #Region " Web Form Designer Generated Code " > > 'This call is required by the Web Form Designer. > <System.Diagnostics.DebuggerStepThrough()> Private Sub > InitializeComponent() > > End Sub > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Init > 'CODEGEN: This method call is required by the Web Form > Designer > 'Do not modify it using the code editor. > BindData() > InitializeComponent() > End Sub > > #End Region > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) > > End Sub > > > Sub BindData() > Dim dbConn As New OleDbConnection() > dbConn.ConnectionString = >
"provider=sqloledb;Server=SERVERNAME;Database=User ;UID=USERID;PWD=PASSWORD" > Dim oAdapter As New OleDbDataAdapter("SELECT * FROM T_Group
", > dbConn) > Dim dsData As New DataSet() > oAdapter.Fill(dsData) > > dgData.AllowPaging = False > dgData.AllowSorting = False > dgData.AutoGenerateColumns = False > 'dgData.EnableViewState = False > > Dim x As Integer > For x = 0 To dsData.Tables(0).Columns.Count - 1 > Dim bcCol As New BoundColumn() > bcCol.HeaderText =
dsData.Tables(0).Columns(x).ColumnName > bcCol.DataField = dsData.Tables(0).Columns(x).Caption > dgData.Columns.Add(bcCol) > bcCol = Nothing > Next > > Dim bcEdit As New EditCommandColumn() > bcEdit.ButtonType = ButtonColumnType.PushButton > bcEdit.EditText = "Edit" > bcEdit.CancelText = "Cancel" > bcEdit.UpdateText = "Save" > dgData.Columns.Add(bcEdit) > bcEdit = Nothing > > dgData.DataSource = dsData.Tables(0) > dgData.DataBind() > > AddHandler dgData.CancelCommand, AddressOf dgData_cmdCancel > AddHandler dgData.EditCommand, AddressOf dgData_cmdEdit > > plcData.Controls.Add(dgData) > End Sub > > > Sub dgData_cmdSave(ByVal sender As Object, ByVal e As > System.Web.UI.WebControls.DataGridCommandEventArgs ) > dgData.EditItemIndex = -1 > Response.Write(e.CommandName) > dgData.DataBind() > End Sub > > > Sub dgData_cmdCancel(ByVal sender As Object, ByVal e As > System.Web.UI.WebControls.DataGridCommandEventArgs ) > dgData.EditItemIndex = -1 > Response.Write(e.CommandName) > dgData.DataBind() > End Sub > > > Sub dgData_cmdEdit(ByVal sender As Object, ByVal e As > System.Web.UI.WebControls.DataGridCommandEventArgs ) > dgData.EditItemIndex = CInt(e.Item.ItemIndex) > Response.Write(e.CommandName) > dgData.DataBind() > End Sub > End Class
Mark,
It took a little while of playing to get it to work, but as it turns out all
I did was move the Call BindData() statement which is in the Page_Init sub
so that it is below the call to: InitializeComponent
(I should have seen it without recreating everything!)
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Call BindData()
End Sub
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Mark" <ma**********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Justin,
I appreciate you taking a look at this.
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="DynaGrid.aspx.vb" Inherits="MMDG.DynaGrid"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>DynaGrid</title> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"> <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:PlaceHolder ID="plcData" Runat="server"></asp:PlaceHolder> </form> </body> </HTML> "S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message news:uJ**************@TK2MSFTNGP11.phx.gbl... Mark,
Sorry I just wasn't specific. I'll chalk up my lack of presenting a logical request to the amount of sleep I had at the time. :)
Could you please also post the designer's code. Then I can recreate the entire page and take a look.
Sincerely,
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche "Mark" <ma**********@yahoo.com> wrote in message news:ul**************@TK2MSFTNGP11.phx.gbl... I did post the code.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... > Mark, > > Make sure that viewstate is on and that the grid is recreated every page > load. > > If these two things are done it should be working. > > If you'd like me to take a look at the code post it and I'll see if
I can > get it to work. > > -- > S. Justin Gengo, MCP > Web Developer > > Free code library at: > www.aboutfortunate.com > > "Out of chaos comes order." > Nietzche > "Mark" <ma**********@yahoo.com> wrote in message > news:39**************************@posting.google.c om... > > I have been working for quite some time on this issue which in theory > > should be quite simple. The problem is that the Cancel and Save > > events are not fired when their respective buttons are clicked. > > > > I have read several posts which say to put your column generating > > section in the Page_Init section and it will solve the > > problem....however, it hasn't solved mine. > > > > Can somebody please take a look at this and provide any insight if > > possible? > > > > Thanks, > > Mark > > > > > > > > > > Imports System > > Imports System.Data > > Imports System.Data.OleDb > > > > Public Class DynaGrid > > > > Inherits System.Web.UI.Page > > Protected WithEvents plcData As > > System.Web.UI.WebControls.PlaceHolder > > Protected WithEvents dgData As New > > System.Web.UI.WebControls.DataGrid() > > > > #Region " Web Form Designer Generated Code " > > > > 'This call is required by the Web Form Designer. > > <System.Diagnostics.DebuggerStepThrough()> Private Sub > > InitializeComponent() > > > > End Sub > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As > > System.EventArgs) Handles MyBase.Init > > 'CODEGEN: This method call is required by the Web Form > > Designer > > 'Do not modify it using the code editor. > > BindData() > > InitializeComponent() > > End Sub > > > > #End Region > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e
As > > System.EventArgs) > > > > End Sub > > > > > > Sub BindData() > > Dim dbConn As New OleDbConnection() > > dbConn.ConnectionString = > > >
"provider=sqloledb;Server=SERVERNAME;Database=User ;UID=USERID;PWD=PASSWORD" > > Dim oAdapter As New OleDbDataAdapter("SELECT * FROM
T_Group ", > > dbConn) > > Dim dsData As New DataSet() > > oAdapter.Fill(dsData) > > > > dgData.AllowPaging = False > > dgData.AllowSorting = False > > dgData.AutoGenerateColumns = False > > 'dgData.EnableViewState = False > > > > Dim x As Integer > > For x = 0 To dsData.Tables(0).Columns.Count - 1 > > Dim bcCol As New BoundColumn() > > bcCol.HeaderText = dsData.Tables(0).Columns(x).ColumnName > > bcCol.DataField = dsData.Tables(0).Columns(x).Caption > > dgData.Columns.Add(bcCol) > > bcCol = Nothing > > Next > > > > Dim bcEdit As New EditCommandColumn() > > bcEdit.ButtonType = ButtonColumnType.PushButton > > bcEdit.EditText = "Edit" > > bcEdit.CancelText = "Cancel" > > bcEdit.UpdateText = "Save" > > dgData.Columns.Add(bcEdit) > > bcEdit = Nothing > > > > dgData.DataSource = dsData.Tables(0) > > dgData.DataBind() > > > > AddHandler dgData.CancelCommand, AddressOf
dgData_cmdCancel > > AddHandler dgData.EditCommand, AddressOf dgData_cmdEdit > > > > plcData.Controls.Add(dgData) > > End Sub > > > > > > Sub dgData_cmdSave(ByVal sender As Object, ByVal e As > > System.Web.UI.WebControls.DataGridCommandEventArgs ) > > dgData.EditItemIndex = -1 > > Response.Write(e.CommandName) > > dgData.DataBind() > > End Sub > > > > > > Sub dgData_cmdCancel(ByVal sender As Object, ByVal e As > > System.Web.UI.WebControls.DataGridCommandEventArgs ) > > dgData.EditItemIndex = -1 > > Response.Write(e.CommandName) > > dgData.DataBind() > > End Sub > > > > > > Sub dgData_cmdEdit(ByVal sender As Object, ByVal e As > > System.Web.UI.WebControls.DataGridCommandEventArgs ) > > dgData.EditItemIndex = CInt(e.Item.ItemIndex) > > Response.Write(e.CommandName) > > dgData.DataBind() > > End Sub > > End Class > >
Mark,
Everything seems to be working for me. I would suggest however that you look
into creating your datagrid in a user control and add the user control to
the page dynamically. That way a lot of the page rendering and post back
event handlers are created for you.
Take a look at the code I offer on my website: www.aboutfortunate.com on
placing user control's on a page dynamically. It should get you started.
Just search for: Dynamic User Controls
I hope this helps.
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Mark" <ma**********@yahoo.com> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl... Justin,
Thanks for looking at this.
How many times does the dgData_cmdEdit event get called when you request
the page? Every time I request the page, this event runs twice (I don't have Zone Alarm). If I remove the AddHandler section, then it only runs once. It's as though the AddHandler actually forces the event to run when it's created.
I have never been able to ge the Save or Cancel events to fire under any circumstance.
Another issue I have found: if you click on the edit button for the first item in the grid, it goes into edit mode. If you then click on the edit button for the second item in the list it wil go into edit mode. Then, if you go back to the first item and click on Edit, it will not go into edit mode (edit mode stays on the second line).
I originally thought this was due to viewstate for the dg, but even disabling it did not work.
Thanks, MM
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message news:eC**************@TK2MSFTNGP10.phx.gbl... Mark,
It took a little while of playing to get it to work, but as it turns out all I did was move the Call BindData() statement which is in the Page_Init
sub so that it is below the call to: InitializeComponent
(I should have seen it without recreating everything!)
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Call BindData()
End Sub
Sincerely,
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche "Mark" <ma**********@yahoo.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Justin,
I appreciate you taking a look at this.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DynaGrid.aspx.vb" Inherits="MMDG.DynaGrid"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>DynaGrid</title> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"> <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:PlaceHolder ID="plcData" Runat="server"></asp:PlaceHolder> </form> </body> </HTML> "S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message news:uJ**************@TK2MSFTNGP11.phx.gbl... > Mark, > > Sorry I just wasn't specific. I'll chalk up my lack of presenting a logical > request to the amount of sleep I had at the time. :) > > Could you please also post the designer's code. Then I can recreate the > entire page and take a look. > > Sincerely, > > -- > S. Justin Gengo, MCP > Web Developer > > Free code library at: > www.aboutfortunate.com > > "Out of chaos comes order." > Nietzche > "Mark" <ma**********@yahoo.com> wrote in message > news:ul**************@TK2MSFTNGP11.phx.gbl... > > I did post the code. > > > > > > "S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message > > news:%2****************@TK2MSFTNGP11.phx.gbl... > > > Mark, > > > > > > Make sure that viewstate is on and that the grid is recreated every page > > > load. > > > > > > If these two things are done it should be working. > > > > > > If you'd like me to take a look at the code post it and I'll see if I > can > > > get it to work. > > > > > > -- > > > S. Justin Gengo, MCP > > > Web Developer > > > > > > Free code library at: > > > www.aboutfortunate.com > > > > > > "Out of chaos comes order." > > > Nietzche > > > "Mark" <ma**********@yahoo.com> wrote in message > > > news:39**************************@posting.google.c om... > > > > I have been working for quite some time on this issue which in theory > > > > should be quite simple. The problem is that the Cancel and
Save > > > > events are not fired when their respective buttons are
clicked. > > > > > > > > I have read several posts which say to put your column generating > > > > section in the Page_Init section and it will solve the > > > > problem....however, it hasn't solved mine. > > > > > > > > Can somebody please take a look at this and provide any
insight if > > > > possible? > > > > > > > > Thanks, > > > > Mark > > > > > > > > > > > > > > > > > > > > Imports System > > > > Imports System.Data > > > > Imports System.Data.OleDb > > > > > > > > Public Class DynaGrid > > > > > > > > Inherits System.Web.UI.Page > > > > Protected WithEvents plcData As > > > > System.Web.UI.WebControls.PlaceHolder > > > > Protected WithEvents dgData As New > > > > System.Web.UI.WebControls.DataGrid() > > > > > > > > #Region " Web Form Designer Generated Code " > > > > > > > > 'This call is required by the Web Form Designer. > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub > > > > InitializeComponent() > > > > > > > > End Sub > > > > > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal
e As > > > > System.EventArgs) Handles MyBase.Init > > > > 'CODEGEN: This method call is required by the Web Form > > > > Designer > > > > 'Do not modify it using the code editor. > > > > BindData() > > > > InitializeComponent() > > > > End Sub > > > > > > > > #End Region > > > > > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As > > > > System.EventArgs) > > > > > > > > End Sub > > > > > > > > > > > > Sub BindData() > > > > Dim dbConn As New OleDbConnection() > > > > dbConn.ConnectionString = > > > > > > > > > >
"provider=sqloledb;Server=SERVERNAME;Database=User ;UID=USERID;PWD=PASSWORD" > > > > Dim oAdapter As New OleDbDataAdapter("SELECT * FROM T_Group ", > > > > dbConn) > > > > Dim dsData As New DataSet() > > > > oAdapter.Fill(dsData) > > > > > > > > dgData.AllowPaging = False > > > > dgData.AllowSorting = False > > > > dgData.AutoGenerateColumns = False > > > > 'dgData.EnableViewState = False > > > > > > > > Dim x As Integer > > > > For x = 0 To dsData.Tables(0).Columns.Count - 1 > > > > Dim bcCol As New BoundColumn() > > > > bcCol.HeaderText = dsData.Tables(0).Columns(x).ColumnName > > > > bcCol.DataField =
dsData.Tables(0).Columns(x).Caption > > > > dgData.Columns.Add(bcCol) > > > > bcCol = Nothing > > > > Next > > > > > > > > Dim bcEdit As New EditCommandColumn() > > > > bcEdit.ButtonType = ButtonColumnType.PushButton > > > > bcEdit.EditText = "Edit" > > > > bcEdit.CancelText = "Cancel" > > > > bcEdit.UpdateText = "Save" > > > > dgData.Columns.Add(bcEdit) > > > > bcEdit = Nothing > > > > > > > > dgData.DataSource = dsData.Tables(0) > > > > dgData.DataBind() > > > > > > > > AddHandler dgData.CancelCommand, AddressOf dgData_cmdCancel > > > > AddHandler dgData.EditCommand, AddressOf
dgData_cmdEdit > > > > > > > > plcData.Controls.Add(dgData) > > > > End Sub > > > > > > > > > > > > Sub dgData_cmdSave(ByVal sender As Object, ByVal e As > > > > System.Web.UI.WebControls.DataGridCommandEventArgs ) > > > > dgData.EditItemIndex = -1 > > > > Response.Write(e.CommandName) > > > > dgData.DataBind() > > > > End Sub > > > > > > > > > > > > Sub dgData_cmdCancel(ByVal sender As Object, ByVal e As > > > > System.Web.UI.WebControls.DataGridCommandEventArgs ) > > > > dgData.EditItemIndex = -1 > > > > Response.Write(e.CommandName) > > > > dgData.DataBind() > > > > End Sub > > > > > > > > > > > > Sub dgData_cmdEdit(ByVal sender As Object, ByVal e As > > > > System.Web.UI.WebControls.DataGridCommandEventArgs ) > > > > dgData.EditItemIndex = CInt(e.Item.ItemIndex) > > > > Response.Write(e.CommandName) > > > > dgData.DataBind() > > > > End Sub > > > > End Class > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bardo |
last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to
reconize the arrow keys. But I have no luck at all. The problem is that the
keydown event won't fire at all, unless I...
|
by: Jim Heavey |
last post by:
Hello, I am starting to learn how to use the Datagrid and I have a couple of
questions.
My datagrid as a checkbox in it. It looks like the following in the
datagrid...
<asp:TemplateColumn...
|
by: Shourie |
last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle.
1) MainPage_load
2) User control1_Load
user clicks a...
|
by: andla |
last post by:
Hi,
How does events fire in a datagrid.
I know about the problem if turning the viewstate off the events wil
not fire properly even if I rebind the control in every postback. S
then I started...
|
by: RJN |
last post by:
Hi
Sorry for posting again.
I have a datagrid which is put inside a div tag to make it scrollable. I
need to page the datagrid. The page numbers appear at the bottom of the
datagrid and has...
| |
by: tafpin |
last post by:
I have an application with a datagrid. In the IDE I have 2 template
columns. The first has an image button and the second contains a link
button.
According to the results that I get back I must...
|
by: Fueled |
last post by:
Hi everyone!
I've made quite a lot of research on this, and I've tried a couple of
proposed solutions. Nothing has worked for me, but I feel there's not
much I'm missing. So I'm turning to this...
|
by: Jeff User |
last post by:
Hello
..NET 1.1, VS 2003, C# & asp.net
I have tried to follow msdn instructions and samples but I can not get
an event to fire for this button on the datagrid.
There has to be something obvious...
|
by: WhiteWizard |
last post by:
I am trying to implement standard multi-select of rows in a datagrid. That
is, allow the user to use the CTRL & SHIFT keys to select multiple rows in a
datagrid. Then I'll loop through them and...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |