473,856 Members | 1,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=Fal se
AllowSorting=Fa lse Runat=server
AutoGenerateCol umns="False"
GridLines="Hori zontal"
ShowHeader=Fals e ShowFooter=Fals e width=100%
BorderStyle="No ne"
CellPadding="0"
OnEditCommand=" _dgProj_EditCom mand"
DataKeyField="P rojID" >

<Columns>
<asp:EditComman dColumn EditText="Edit
This" CancelText="Can cel This" UpdateText="Upd ate This" />
<asp:BoundColum n DataField=ProjI D
HeaderText="Pro jID" />
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:DataGrid ID="_dgRel"
AllowPaging=Fal se AllowSorting=Fa lse Runat=server
AutoGenerateCol umns="False"
GridLines="None "
ShowHeader=fals e ShowFooter=Fals e width=100%
BorderStyle="No ne"
CellPadding="0"
OnEditCommand=" _dgRel_EditComm and"
DataKeyField="R elID"
DataSource='<%# CType
(Container.Data Item,System.Dat a.DataRowView). CreateChildVie
w("RelID") %>'

<Columns>
<asp:EditComman dColumn
EditText="Edit This" CancelText="Can cel This"
UpdateText="Upd ate This" />
<asp:BoundColum n
DataField=RelID HeaderText="Rel ID" />
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>

--CODE BEHIND-----

Imports System.Data
Imports System.Data.Sql Client

Public Class DataGridNesting
Inherits System.Web.UI.P age
Protected WithEvents _dgProj As
System.Web.UI.W ebControls.Data Grid
Protected WithEvents _dgRel As
System.Web.UI.W ebControls.Data Grid
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) 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. ConfigurationSe ttings.AppSetti ngs
("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, "tblProject s")
daRelease.Fill( DS, "tblRelease ")

'Join (Many)
tblRelease.Proj ID=tblProjects. ProjID(One)
Dim RelIDParent As DataColumn = DS.Tables
("tblProjects") .Columns("ProjI D")
Dim RelIDChild As DataColumn = DS.Tables
("tblRelease"). Columns("ProjID ")
Dim RelIDRel As DataRelation = New DataRelation
("RelID", RelIDParent, RelIDChild, False)
DS.Relations.Ad d(RelIDRel)

_dgProj.DataSou rce = DS.Tables
("tblProjects") .DefaultView
_dgProj.DataBin d()

Catch ex As SqlException

End Try

End Sub

Public Sub _dgProj_EditCom mand(ByVal source As Object,
ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs)
Handles _dgProj.EditCom mand
source.EditItem Index = e.Item.ItemInde x
BindDg()
End Sub

Public Sub _dgProj_CancelC ommand(ByVal source As
Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs)
Handles _dgProj.CancelC ommand
source.EditItem Index = -1
BindDg()
End Sub

Public Sub _dgRel_EditComm and(ByVal source As Object,
ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs)
Handles _dgRel.EditComm and
source.EditItem Index = e.Item.ItemInde x
BindDg()
End Sub

Public Sub _dgRel_CancelCo mmand(ByVal source As
Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs)
Handles _dgRel.CancelCo mmand
source.EditItem Index = -1
BindDg()
End Sub
End Class

Nov 17 '05 #1
0 2264

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

Similar topics

0
1228
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 after the first click, the even will fire correctly Has anyone had this problem before Thanks.........Bill
4
5983
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, they want the text value. Any advice, samples or places to read are appreciated. Thanks.
0
1064
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 call the LoadDataRow method to update the DataTable "in place". I've been using boundcolumns for the invisible fields, which worked fine, but now I've run into an issue with them. On the second of the 3 pages, the user can modify certain...
0
1245
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 the code for my inner datagrid's EditCommand: public void dgInner_EditCommand(object sender, DataGridCommandEventArgs e) {
1
1694
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 if the record is part of an existing relationship, so the user can't update it. The "CareTypeID" field is the key and is invisible to the user. Here is the db table columns: CareTypeID
1
1384
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 Edit button, the datagrid disappears. Have I lost my datasource during postbacks or something? Here's my code: private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) {
1
1842
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 GridDataLangs(DataTable vDataTable){ DataGrid myGrid = new DataGrid(); myGrid.AutoGenerateColumns = false;
1
1248
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 is correct - that ViewState must be turned on. If this is true, does anyone know why it's true? Many TIA, -- Joe
1
2252
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 button click event fires, no problem. But the event for the EditCommand does not fire. Any Ideas? Any one else seen this? Here is some code: <cc2:ScriptManager ID="atlasScriptManager" runat="server"
0
9921
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11065
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10795
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9536
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7098
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5763
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4581
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 we have to send another system
3
3203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.