473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

EditCommand on Nested DataGrid

I can't figure out how to use the EditCommand for the
nested datagrid .. HELP PLEASE ;-) It works perfectly for
the parent datagrid, but will not display, even though the
EditCommand event is firing for the child datagrid. I
have set up a test page for myself to see if I can get
this to work ..any help is appreciated! Thanks in advance

(This is my complete page and code behind)

<asp:DataGrid ID="_dgProj" AllowPaging=False
AllowSorting=False Runat=server
AutoGenerateColumns="False"
GridLines="Horizontal"
ShowHeader=False ShowFooter=False width=100%
BorderStyle="None"
CellPadding="0"
OnEditCommand="_dgProj_EditCommand"
DataKeyField="ProjID" >

<Columns>
<asp:EditCommandColumn EditText="Edit
This" CancelText="Cancel This" UpdateText="Update This" />
<asp:BoundColumn DataField=ProjID
HeaderText="ProjID" />
<asp:TemplateColumn>
<ItemTemplate>
<asp:DataGrid ID="_dgRel"
AllowPaging=False AllowSorting=False Runat=server
AutoGenerateColumns="False"
GridLines="None"
ShowHeader=false ShowFooter=False width=100%
BorderStyle="None"
CellPadding="0"
OnEditCommand="_dgRel_EditCommand"
DataKeyField="RelID"
DataSource='<%# CType
(Container.DataItem,System.Data.DataRowView).Creat eChildVie
w("RelID") %>'

<Columns>
<asp:EditCommandColumn
EditText="Edit This" CancelText="Cancel This"
UpdateText="Update This" />
<asp:BoundColumn
DataField=RelID HeaderText="RelID" />
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

--CODE BEHIND-----

Imports System.Data
Imports System.Data.SqlClient

Public Class DataGridNesting
Inherits System.Web.UI.Page
Protected WithEvents _dgProj As
System.Web.UI.WebControls.DataGrid
Protected WithEvents _dgRel As
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.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Page.IsPostBack = False Then
'Initialize first time page loads
BindDg()
End If

End Sub
Public Sub BindDg()
Dim DS As DataSet
Dim Conn1 As New SqlConnection
(Configuration.ConfigurationSettings.AppSettings
("connString"))

Try
Dim daProj As New SqlDataAdapter("SELECT *
FROM tblProjects", Conn1)
Dim daRelease As New SqlDataAdapter("SELECT *
FROM tblRelease", Conn1)

DS = New DataSet()
daProj.Fill(DS, "tblProjects")
daRelease.Fill(DS, "tblRelease")

'Join (Many)
tblRelease.ProjID=tblProjects.ProjID(One)
Dim RelIDParent As DataColumn = DS.Tables
("tblProjects").Columns("ProjID")
Dim RelIDChild As DataColumn = DS.Tables
("tblRelease").Columns("ProjID")
Dim RelIDRel As DataRelation = New DataRelation
("RelID", RelIDParent, RelIDChild, False)
DS.Relations.Add(RelIDRel)

_dgProj.DataSource = DS.Tables
("tblProjects").DefaultView
_dgProj.DataBind()

Catch ex As SqlException

End Try

End Sub

Public Sub _dgProj_EditCommand(ByVal source As Object,
ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Handles _dgProj.EditCommand
source.EditItemIndex = e.Item.ItemIndex
BindDg()
End Sub

Public Sub _dgProj_CancelCommand(ByVal source As
Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Handles _dgProj.CancelCommand
source.EditItemIndex = -1
BindDg()
End Sub

Public Sub _dgRel_EditCommand(ByVal source As Object,
ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Handles _dgRel.EditCommand
source.EditItemIndex = e.Item.ItemIndex
BindDg()
End Sub

Public Sub _dgRel_CancelCommand(ByVal source As
Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
Handles _dgRel.CancelCommand
source.EditItemIndex = -1
BindDg()
End Sub
End Class

Nov 17 '05 #1
0 2246

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bmoman | last post by:
Hell I have a datagrid with an Edit, Update, Cancel button on it. When I click the edit button the first time, the EditCommand event is not fired, but when I click the same button immediately...
4
by: Richard Roche | last post by:
Is it possible to use a drop combo instead of a text box when using the EditCommand in the Datagrid? Many table columns are bound to 'lookup' tables, user's don't care about the foreign keys,...
0
by: Mike | last post by:
I've got an app with a DataTable that gets passed around and modified by datagrids on 3 different asp.net pages. Not all columns need to be displayed, but I need them all in the datagrid so I can...
0
by: Linus | last post by:
Hi, I have a datagrid nested inside another datagrid, the edit/update/cancel command works fine on the outter datagrid but I'm having problems with the inner one. There are 2 problems and here's...
1
by: bill yeager | last post by:
I'm doing an inline edit of an Admin table using the Datagrid. There are three columns in my Admin table. I want to dynamically disable the corresponding "CareType" field (see below) in the grid...
1
by: jacobryce | last post by:
j9 (Programmer) Feb 15, 2005 I have a datagrid with an arraylist as the datasource. I added an Edit, Update, Cancel button column and coded the EditCommand event handler. When I click on the...
1
by: benoit | last post by:
Hi, I created a Dynamic Datagrid and i added an EditCommandColumn to it. Works fine, but my Editcommand eventhandler seems to have a problem with PostBack This is my code private DataGrid...
1
by: Joe | last post by:
Hello All: I have the understanding that the datagrid requires that ViewState be turned on in order to use the ItemCommand, EditCommand,SortCommand, etc event handlers. Does anyone know if this...
1
by: bill | last post by:
I have an update panel that contains a gridview. There are 2 triggers: one for a search button that is outside the panel and one for the gridview EditCommand Event. The search works fine, the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.