Nested GridView Row Event Pandemonium
Dec 7, 2010
I have come across odd behavior involving nested gridview controls and row events. Basically the nested gridview row event will not fire unless it is in the last row of the outer grid. If you explicitly add the row event property to the markup (e.g. OnRowDeleted="gvInner_RowDeleted") then the row event fires for all nested gridviews however it fires twice for the nested gridview in the last row of the outer gridview EDIT: I should note that I am using the SqlDataSource for the outer gridview as it is also editable. This isn't clear in the example.
Markup:
<asp:GridView ID="gvOuter" DataSourceID="sdsOuter" runat="server" OnRowDatabound="DynamicControlAdder" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" ReadOnly="true" />
<asp:TemplateField>
<ItemTemplate>
<asp:UpdatePanel ID="upInner" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvInner" DataSourceId="sdsInner" runat="server" DataKeyNames="Id" AutoGenerateColumns="false">
<Columns>
<asp:CommandField ShowDeleteButton="true" />
<asp:BoundField DataField="Id" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="sdsInner" runat="server"
ProviderName="<%$ ConnectionStrings:YourString.ProviderName %>"
ConnectionString="<%$ ConnectionStrings:YourString %>"
SelectCommand="SELECT * FROM tblInner WHERE OuterTableKey = @OuterTableKey"
DeleteCommand="DELETE FROM tblInner WHERE Id = @Id">
<SelectParameters>
<asp:Parameter Name="OuterTableKey" DefaultValue="0" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="Id" DefaultValue="0" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="sdsOuter" runat="server"
ProviderName="<%$ ConnectionStrings:YourString.ProviderName %>"
ConnectionString="<%$ ConnectionStrings:YourString %>"
SelectCommand="SELECT * FROM tblOuter">
</asp:SqlDataSource>
Code:
Partial Class Testing
Inherits System.Web.UI.UserControl
Protected Sub DynamicControlAdder(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType <> DataControlRowType.DataRow Then
Exit Sub
End If
Dim s As SqlDataSource = CType(e.Row.FindControl("sdsInner"), SqlDataSource)
s.SelectParameters("OuterTableKey").DefaultValue = e.Row.DataItem("Id").ToString()
End Sub
Protected Sub gvInner_RowDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeletedEventArgs) Handles gvInner.RowDeleted
//'This never fires unless it is the last row in the outer gridview
//'also, if this event is declared in the OnRowDeleted property of the inner gridview, this event fires twice if it is in the last row of the outer grid
Dim strFoo As String = "Foo"
End Sub
End Class
View 2 Replies
Similar Messages:
Jan 8, 2011
In a nested GridView (GridView inside a template column of parent GridView). I am binding child GridView to a DataTable in parent GridView's RowDataBound event. this works as it should. But the problem i am facing is in Child GridView's RowDataBound Event, when i try to access e.Row.DataItem property it returns null. I am expecting it to return DataRowView Type. which i will then use to set values of TextBox's.
[code]....
View 1 Replies
Aug 31, 2010
I have a GridView within a GridView. I want o access child gridview's rowupdating event. i want to update row.
this is my GridView's code as follows
[Code]....
View 6 Replies
Dec 4, 2013
I have a Master/Slave GrisViews or some say Parent/Child GridViews.
i want to set my button visible=false in the child gridview if data is not exist.
i try this:
Protected Sub gv_child_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#FFC080';")
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='';")
Dim lblitemid As Label = CType(e.Row.Cells(1).Controls(1), Label)
Dim lblphoto As Label = CType(e.Row.Cells(11).Controls(1), Label)
[Code]......
but it does not working. the button is still there.
View 1 Replies
Aug 2, 2013
I created nested gridview refereing asp.snippets.. Its working fine now requirement is to add Checkbox within child grid.. i added childgrid by
</asp:TemplateField>
<asp:TemplateField HeaderText="Approve">
<ItemTemplate>
[Code]...
How to find child grid check box control
View 1 Replies
Oct 1, 2010
I have a Parent gridview with a nested gridview. Edit on the parent works fine. On the nested child gridview, when I click the edit button, the line goes into edit mode, but the parent row collapses. To correct I added javascript to call the javascript function that is used to expand and collapse the rows. It is located in the RowDataBound event of the parent gridview.
Based on the code samples I have, the way the process should work when the edit button is clicked is the RowCommand and then the RowEditing events for the child gridview are supposed to fire, followed by the RowDataBound for the parent. The child events are firing after the parent though. This wouldn't be a problem except that I am retrieving the parent line that holds the child record being edited so that value can be fed to the javascript function to expand the row. How can I fix this or work around it?
View 2 Replies
Mar 1, 2011
I'm trying to create a nested gridview, but I'm stuck at the editing/deleting part of the nested gridview. (Below is my code).The nested gridviews are filling out nice, I've set the DeleteParameter in the SQLDataSource, but I'm still getting this error when trying to delete a criteria: 'The Gridview 'gvCriteria' fired event RowDeleting which wasn't handled.'I've tried to create a method 'gvCriteria_RowDeleting', but that didn't seem to work out.Someone who can give me a piece of advice? Would it be possible to fill the gridview without using gvDomain_rowDataBound? Dries
[Code]....
[Code]....
And the C# behind:
[Code]....
View 10 Replies
Jan 27, 2011
I have parent gridview5 and nested child gridview6 within it. The page is working as expected and formatted as i need it now.. I added a select button to the child gridview6 and when i click on it i get an error: {"Object reference not set to an instance of an object."}
I found examples of using the find control, but within the parent gridview.. and i use that fine with other controls.. but cant figure out the right combination of finding the selected row for the nested gridview so that i can display a modalpopup.
View 8 Replies
Jan 24, 2016
I have followed this article: [URL] ....
I have added textbox and checkbox in nested(child) gridview....
View 1 Replies
Jul 28, 2010
i have two nested gridview inside an update panel. there is a button called btnPhoneEdit inside the child grid view. when the button gets clicked, it do cause partial post back as expected but it fails to invoke btnPhoneEdit_Click.
here is how my grid view looks like and how i add my custom data source to both parent and child grid view.
[Code]....
[Code]....
View 1 Replies
Jun 17, 2010
Is there a better, cleaner way to do this in ASP.NET 2.0?
An ASP.NET 2.0 page displays a datalist of records. Each record can have many dates, so the dates are in a nested gridview (I chose a gridview over a datalist here because we want to be able to delete a date and this is easier done in a gridview). The parent record can never be deleted.
The display works fine: the nested gridview gets its datasource during the parent datalist's OnItemDataBound event.
The problem: the nested gridview's delete function. The date gets deleted without a problem (handled in the OnRowDeleting event), but somehow the redisplay is untying all the other nested gridviews from their datasources. The delete does not appear to cause a page postback, so I don't know how the other nested gridviews are losing their datasources.
View 3 Replies
Dec 5, 2013
In Nested Grid, we get a '+' sign. The problem is that '+' sign appears all times, even if there are no child records for that row. 1. Can we enable/disable OR Hide/Unhide '+' sign. depending on if child rows exits.2. OR alteast we can put some bgcolor indicating to user that this record do have child rows. Without any indicator user may feel quite annoying to click on '+' sign and nothing happens.
View 1 Replies
Jan 24, 2016
I have designed a collapsible nested gridview project using this article as a reference Collapsible Nested GridView with Paging using ASP.Net. I am trying to modify the code to collapse a gridview when another gridview is expanded so that only one nested gridview will be open at a time.
View 1 Replies
Nov 24, 2010
I have the following situation:
Updatepanel
dynamically loaded Usercontrol
Button
UpdatePanel2
I am loading a Usercontrol with another Updatepanel inside of it. Now in this usercontrol, i have a button which is registered as an async postback trigger for the 2nd Updatepanel. However when I click the button, nothing happens. While debugging, it does not even step into the Click event of the Button which sits in the usercontrol of course. The Parent Updatepanel ist set to Updatemode conditional and hildrenAsTriggers="false". The nested UpdatePanel2 is set to Updatemode=Conditional. I just want the Parent Updatepanel to do nothing and the button to fire its event so that I can load some data in the nested updatepanel.
View 1 Replies
Feb 12, 2010
[Code]....
[Code]....
View 2 Replies
Jun 4, 2010
I have a detailsview that contains a radio button list, and a couple of check boxes. I want to run some code when the radiobuttonlist selection is changed, or when the checkboxes are checked or unchecked. how I can do that even though the controls are nested inside another control?
View 2 Replies
Dec 1, 2010
In nested gridview, i am finding some problem, i want to show child Grid headers in Parent Gridview. Can anyone tell me that how it is possible? Its very urgent. Waiting for quick response.
View 1 Replies
Jan 28, 2011
I am upgrading a website project from asp.net 3.5 to 4.0. I went through the upgrade wizard and site compiled and built fine. But immediately I have encountetred a problem.I have 3 nested ListViews all using the ItemCommand event. Under 4.0 once the ItemCommand event has fired on the inner ListView it then bubbles up and fires on the parent and finally the grandparent.This is a change in behaviour from 3.5 where only the inner ListView event fires. While I can code round this I am worried about these subtly changes between the two versions.
View 1 Replies
Oct 8, 2012
while surfing code I had seen your Application Grid inside Grid.
[URL]
I need the Grid inside Gridwith enable first + symbol when click on second one first one should be hide
View 1 Replies
Jan 23, 2011
I don't understand because the click event doesn't fire in ascx control nested in masterpage.
The scenario is:
In Page Pre-Init i load a particular MasterPage, one of these have a ascx control with LogOff Button.
The ascx is showed correctly but doesn't fire the button click event that allow me to logoff.
I haven't load the control programmatically but directly in masterpage:
[Code]....
[Code]....
View 4 Replies
Jul 19, 2010
my nested Grid Rowupdating Event is not fired., so i want to declare event in code., how can i do this/
[Code]....
View 2 Replies
May 7, 2015
URL....When the user creates a new child record (2nd gridview) how can I ibsert a field from the parent level (obviously from the line where they clicked from).
View 1 Replies
Oct 12, 2010
i have the following nested gridview
i could get the inner gridview onRowDataBound working by setting that directly in the gridview
but i cannot get the linkbutton's onrowCommad inside the inner gridview working!!!
it does not fire the event even i have set it directly in the gridview
here is the code in my app_code page
[code]....
View 12 Replies
Oct 28, 2010
I have a nested gridview which has been working fine. Now I need to turn the inner gridview off based on some condition: a IF block is added to the existing RowDataBound event of the outer gridview. Now I'm getting "the Object reference not set to an instance of an object" error. What should be the proper way to go about this? The code:
[code]....
In addition, is there a way to "switch" columns of the inner gridview? For example, column 1 is "City", column 2 is "Price". If user selects to sort by "Price", I woud like column 1 be "Price" and column 2 be "City". Is this has to be done programmatically or if there's other way?
View 3 Replies
Jan 3, 2010
I have a nested gridview dynamically added. It seems I resolved all issues with the loading this control on a parent page along with other controls and I can trigger the edit of the first level - the master part of the gridview. However, I cannot trigger the edit on a child gridview.
OnRowEditing="grdChildGridEdit_RowEditing"
The master and the child gridviews have objectdatasources in a markup but I have to do the additional data binding after the loading the control on the parent page (see the code below). I'm doing that additional data binding only for the master gridview that is working fine and shows the data for the master and the child gridviews. When I click the Edit button on the master gridview it shows text boxes for the editing but when I click the Edit button on the child gridview it's doing nothing and moreover the editing mode for the master gridview is going back to the initial stage (labels).
I was trying to trigger it throughuse the registering the event:
[code]....
View 5 Replies