473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some events are not executed from child gridview

I have a perent gridview which includes in a template field a child
gridview. Child gridview includes command buttons for opening
different windows based on its row selected.

I used the code below. The event for RowDataBound is executed, rows
get different color, but event for RowCommand is not executed. What
could be the problem ?

Thanks a lot in advance.

&nbsp;<asp:Grid View ID="grv_batches " runat="server"
AutoGenerateCol umns="False"
DataKeyNames="c ountry_no,produ ct_no,client_no " CssClass="GridV iew" >
<Columns>
<asp:ButtonFiel d CommandName="Se nd" Text="Finish" >
<ControlStyle CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >
<asp:BoundFie ld DataField="Coun try_name"
HeaderText="Cou ntry" />
<asp:BoundFie ld DataField="prod uct_name"
HeaderText="Pro duct" />
<asp:BoundFie ld DataField="clie nt_name"
HeaderText="Com pany" />
<asp:TemplateFi eld HeaderText="Det ails">
<ItemTemplate >
<asp:GridView ID="grv_reports " runat="server"
AutoGenerateCol umns="False" CssClass="GridV iew"
OnRowCommand="g rv_subscr_repor ts_RowCommand"
OnRowDataBound= "grv_subscr_rep orts_RowDataBou nd">
<Columns>
<asp:ButtonFiel d CommandName="Su b"
Text="S">
<ControlStyle
CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >

Protected Sub grv_subscr_repo rts_RowCommand( ByVal sender As Object,
ByVal e As System.Web.UI.W ebControls.Grid ViewCommandEven tArgs)
If e.CommandName = "Sub" Then

Protected Sub grv_subscr_repo rts_RowDataBoun d(ByVal sender As
Object, ByVal e As System.Web.UI.W ebControls.Grid ViewRowEventArg s)
If e.Row.RowType = DataControlRowT ype.DataRow Then
Select Case e.Row.Cells(11) .Text 'report status
Case "New"
e.Row.BackColor = Drawing.Color.L ightGreen

Feb 15 '07 #1
4 4189
Do you databind the grid initially in

if not page.ispostback then
'...
end if

check?
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"chris" <CL*****@gmail. comwrote in message
news:11******** ************@a7 5g2000cwd.googl egroups.com...
>I have a perent gridview which includes in a template field a child
gridview. Child gridview includes command buttons for opening
different windows based on its row selected.

I used the code below. The event for RowDataBound is executed, rows
get different color, but event for RowCommand is not executed. What
could be the problem ?

Thanks a lot in advance.

&nbsp;<asp:Grid View ID="grv_batches " runat="server"
AutoGenerateCol umns="False"
DataKeyNames="c ountry_no,produ ct_no,client_no " CssClass="GridV iew" >
<Columns>
<asp:ButtonFiel d CommandName="Se nd" Text="Finish" >
<ControlStyle CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >
<asp:BoundFie ld DataField="Coun try_name"
HeaderText="Cou ntry" />
<asp:BoundFie ld DataField="prod uct_name"
HeaderText="Pro duct" />
<asp:BoundFie ld DataField="clie nt_name"
HeaderText="Com pany" />
<asp:TemplateFi eld HeaderText="Det ails">
<ItemTemplate >
<asp:GridView ID="grv_reports " runat="server"
AutoGenerateCol umns="False" CssClass="GridV iew"
OnRowCommand="g rv_subscr_repor ts_RowCommand"
OnRowDataBound= "grv_subscr_rep orts_RowDataBou nd">
<Columns>
<asp:ButtonFiel d CommandName="Su b"
Text="S">
<ControlStyle
CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >

Protected Sub grv_subscr_repo rts_RowCommand( ByVal sender As Object,
ByVal e As System.Web.UI.W ebControls.Grid ViewCommandEven tArgs)
If e.CommandName = "Sub" Then

Protected Sub grv_subscr_repo rts_RowDataBoun d(ByVal sender As
Object, ByVal e As System.Web.UI.W ebControls.Grid ViewRowEventArg s)
If e.Row.RowType = DataControlRowT ype.DataRow Then
Select Case e.Row.Cells(11) .Text 'report status
Case "New"
e.Row.BackColor = Drawing.Color.L ightGreen
Feb 15 '07 #2
The first/parent grid is databinded from a button because user makes
selection on countries, products, clients and depending on them SQL is
created and bind the grid. The second/child gridview, shows more
details for each row of parent grid and it's data is binded in the
RowDataBound of the parent gridview.

Since RowDataBound of child gridview works for applying colors to it's
rows, shouldn't the RowCommand event work also ?

Feb 16 '07 #3
Yup,

point was that if grid is databound on every request, it would prevent
rowcommand from working.

post the code
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"chris" <CL*****@gmail. comwrote in message
news:11******** **************@ j27g2000cwj.goo glegroups.com.. .
The first/parent grid is databinded from a button because user makes
selection on countries, products, clients and depending on them SQL is
created and bind the grid. The second/child gridview, shows more
details for each row of parent grid and it's data is binded in the
RowDataBound of the parent gridview.

Since RowDataBound of child gridview works for applying colors to it's
rows, shouldn't the RowCommand event work also ?
Feb 16 '07 #4
thanks a lot for your message.

I tried in debug mode break points to check whether code is executed
in RowCommand event, but nothing. Only code in RowDataBound of child
gridview is executed. I tried to change the name of event of
RowCommand in asp and it gives an error that event is not found, so it
regognises it, just not executes it.

Here is the code:

Protected Sub btn_show_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles btn_show.Click

refresh_gridvie w_data()

End Sub

Protected Sub refresh_gridvie w_data()

Dim sdsc As New SqlDataSource
Dim var_SQL As String
'------------------------------------------------------------------------------------------------------------------------------------

sdsc.Connection String =
ConfigurationMa nager.Connectio nStrings("Conne ctionString1"). ConnectionStrin g
sdsc.DataSource Mode = SqlDataSourceMo de.DataReader

var_SQL = "SELECT DISTINCT dbo.Report.coun try_no,
dbo.Report.prod uct_no, dbo.Report.clie nt_no, "

sdsc.SelectComm and = var_SQL

grv_batches.Dat aSource = sdsc
grv_batches.Dat aBind()

End Sub

Protected Sub grv_batches_Row Created(ByVal sender As Object, ByVal e
As System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
grv_batches.Row Created
If e.Row.RowType = DataControlRowT ype.DataRow Then
Dim sdsc As New SqlDataSource
Dim grv_rep As GridView = e.Row.FindContr ol("grv_reports ")

sdsc.Connection String =
ConfigurationMa nager.Connectio nStrings("Conne ctionString1"). ConnectionStrin g

sdsc.SelectComm andType =
SqlDataSourceCo mmandType.Store dProcedure
sdsc.SelectComm and = "STP_slct_Repor ts"

sdsc.SelectPara meters.Add("cou ntry_no",
grv_batches.Dat aKeys(e.Row.Row Index).Values(" country_no"))
sdsc.SelectPara meters.Add("pro duct_no",
grv_batches.Dat aKeys(e.Row.Row Index).Values(" product_no"))
sdsc.SelectPara meters.Add("cli ent_no",
grv_batches.Dat aKeys(e.Row.Row Index).Values(" client_no"))

grv_rep.DataSou rce = sdsc
grv_rep.DataBin d()
End If

Protected Sub grv_subscr_repo rts_RowCommand( ByVal sender As Object,
ByVal e As System.Web.UI.W ebControls.Grid ViewCommandEven tArgs)
If e.CommandName = "Report" Then
'one_all = 1 'one report will be edited
If (Not
Page.ClientScri pt.IsStartupScr iptRegistered(M e.GetType(), "Report"))
Then 'Check to see if the startup script is already registered.
Page.ClientScri pt.RegisterStar tupScript(Me.Ge tType(),
"Report", "window.open('R eport.aspx',
'','dialogHeigh t=850px,Width=8 00px,menubar=No ,toolbar=no,scr ollbars=yes');
", True)
End If
End If
End Sub

Protected Sub grv_subscr_repo rts_RowDataBoun d(ByVal sender As
Object, ByVal e As System.Web.UI.W ebControls.Grid ViewRowEventArg s)
If e.Row.RowType = DataControlRowT ype.DataRow Then
Select Case e.Row.Cells(11) .Text 'report status
Case "Cancelled"
e.Row.BackColor = Drawing.Color.O rangeRed
Case "On-Hold"
e.Row.BackColor = Drawing.Color.O range
Case "Finished"
e.Row.BackColor = Drawing.Color.L ightSteelBlue
Case "New"
e.Row.BackColor = Drawing.Color.L ightGreen
End Select
End If
End Sub
&nbsp;<asp:Grid View ID="grv_batches " runat="server"
AutoGenerateCol umns="False"
DataKeyNames="c ountry_no,produ ct_no,client_no " CssClass="GridV iew" >
<Columns>
<asp:ButtonFiel d CommandName="Fi nish" Text="Finish" >
<ControlStyle CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >
<asp:BoundFie ld DataField="Coun try_name"
HeaderText="Cou ntry" />
<asp:BoundFie ld DataField="prod uct_name"
HeaderText="Pro duct" />
<asp:BoundFie ld DataField="clie nt_name"
HeaderText="Com pany" />
<asp:BoundFie ld DataField="stat us_name"
HeaderText="Sta tus" />
<asp:BoundFie ld HeaderText="Fin ish Status" />
<asp:TemplateFi eld HeaderText="Sub s">
<ItemTemplate >
<asp:GridView ID="grv_reports " runat="server"
AutoGenerateCol umns="False" CssClass="GridV iew"
OnRowCommand="g rv_subscr_repor ts_RowCommand"
OnRowDataBound= "grv_subscr_rep orts_RowDataBou nd">
<Columns>
<asp:ButtonFiel d CommandName="Su b"
Text="S">
<ControlStyle
CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >
<asp:ButtonFiel d CommandName="Re port"
Text="R">
<ControlStyle
CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >
<asp:ButtonFiel d CommandName="Hi story"
Text="H">
<ControlStyle
CssClass="GridV iew_LinkButtons " />
</asp:ButtonField >
<asp:BoundFie ld DataField="note "
HeaderText="N">
<ItemStyle Font-Bold="True"
ForeColor="Red" HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="comp any_name"
HeaderText="Com pany" />
<asp:BoundFie ld DataField="full _name"
HeaderText="Use r" />
<asp:BoundFie ld
DataField="proc _deliverable_na me" HeaderText="Del iverable" />
<asp:BoundFie ld
DataField="repo rt_deadline" HeaderText="Dea dline" />
<asp:BoundFie ld
DataField="repo rt_finished" HeaderText="Fin ish" />
<asp:BoundFie ld DataField="dela y"
HeaderText="Del ay">
<ItemStyle ForeColor="Red" />
</asp:BoundField>
<asp:BoundFie ld
DataField="repo rt_importance_s hort_name" HeaderText="Imp " />
<asp:BoundFie ld
DataField="repo rt_status_name" HeaderText="Rep ort Status" />
<asp:BoundFie ld
DataField="sub_ status_name" HeaderText="Sub . Status" />
<asp:BoundFie ld DataField="date _activated"
HeaderText="Dat e Activated" />
<asp:BoundFie ld DataField="sub_ no"
HeaderText="sub _no" Visible="False" />
<asp:BoundFie ld DataField="sub_ detail_no"
HeaderText="sub _detail_no"
Visible="False" />
<asp:BoundFie ld DataField="repo rt_no"
HeaderText="rep ort_no" Visible="False" />
</Columns>
<RowStyle CssClass="GridV iew_Row" />
<HeaderStyle CssClass="GridV iew_Header2" Font-
Size="XX-Small" />
<AlternatingRow Style
CssClass="GridV iew_AlternateRo w" />
</asp:GridView>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
<RowStyle CssClass="GridV iew_Row" />
<HeaderStyle CssClass="GridV iew_Header" />
<AlternatingRow Style CssClass="GridV iew_AlternateRo w" />
</asp:GridView>

Feb 16 '07 #5

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

Similar topics

14
12149
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using events since I never saw it used anywhere in MSDN documentation/samples?! Or it will just break when I upgrade to .NET Framework 2.x in the coming years namespace MyNamespac public delegate void MyDel() public class MyBase public virtual...
7
2691
by: Colin Young | last post by:
I have a UserControl that contains a calendar control. The calendar is not raising events (month navigation, date selections, etc.). I've checked that the OnSelectionChanged event has a handler being registered. Is there anything else obvious or otherwise that I've missed? Is there a problem using it in a UserControl? Thanks Colin
2
1662
by: ads | last post by:
hi guys, Here's the scenario: i have a gridview on a parent page. Then i open another (child) page where i can modify the data on the dridview. How do i update the gridview soon as i do modification and close the child window ? I just need a triger event to rebind the gridview but how can i do that from the child page? Thanks in advance,
1
1507
by: needin4mation | last post by:
protected void Page_Load(object sender, EventArgs e) { TextBox mpTextBox = (TextBox)(Master.FindControl("txtFreeSearch")); Response.Write("mp" + mpTextBox.Text); //only works the second time }
0
2870
by: nitinp | last post by:
I am facing the problem in editing records in child gridview which i have placed in the parent gridview's cell. I have bound both parent and child with different sqlDataSource objects. I have written following code to papulate child gridview and given Edit/Update column in it. protected void gvMaster_RowDataBound(object sender, GridViewRowEventArgs e) { int intMAsterID1; if (e.Row.RowType == DataControlRowType.DataRow) { GridView...
10
2428
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from the codebehind of the UserControl? For instance, suppose that the UserControl is dropped inside one...
1
3397
by: Andrew Hayes | last post by:
I have a parent page with a gridview, and a child page with a formview. Using the solution on velocityreviews: http://www.velocityreviews.com/forums/t80654-solution-raising-an-event-handler-postback-on-parent-window-from-popup-child-window-dialog-box.html I was able to create the Parent and Child Window custom controls and get them to work correctly so that I could select a row in the GridView of the parent page and popup a child...
4
3487
by: =?Utf-8?B?Y2hyaXM=?= | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code below. The event for RowDataBound is executed, rows get different color, but event for RowCommand is not executed. What could be the problem ? Thanks a lot in advance.
0
1522
by: erkbiz | last post by:
Hello, I have an event that I defined with a delegate. When I bind this event to a button and place the event prior to calling base.OnLoad(e) which is called prior to if (!PostBack) the Event works as expected. I now want to use this event in a gridview but when I add it to the gridview the event doesn't fire. For a test I moved the code that binds the button to the event beyond where I call base.OnLoad(e) and after if (!PostBack) and...
0
9629
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
9470
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10069
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
9923
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
5370
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...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4033
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
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.