473,769 Members | 3,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot rebind GridView nested in DataList

Hello everybody

I'm stuck for a long time with the following problem, so I will be
really gratefull if you could help me a bit:

I have a GridView nested in DataList (it's located in DataList's Item
Template together with it's data source).

In OnRowUpdated event of child GridView I'm calling DataBind() on
parent DataList, since I want it to reflect the changes (maybe there's
better way to refresh the datalist?)

I get the following error:
==========
"The ObjectDataSourc e control 'odsGridViewObj ectDataSource' does not
have a naming container. Ensure that the control is added to the page
before calling DataBind. "
==========
It happens when during rebinding of datalist, rebinding of child
gridview is called ( on ItemDataBound event), more precisly when
FindControl is called:

protected void DataList1_ItemD ataBound(Object sender,
System.Web.UI.W ebControls.Data ListItemEventAr gs e) {
odsGridViewObje ctDataSource =
(ObjectDataSour ce)(e.Item.Find Control("odsGri dViewObjectData Source"));

try
{

odsodsGridViewO bjectDataSource .SelectParamete rs["CostID"].DefaultValue
= DataBinder.Eval (e.Item.DataIte m, "CostID").ToStr ing();

}

thank you a LOT

Apr 27 '06 #1
1 3415
I've solved the problem.

I guess calling DataBind() on parent control on OnRowUpdated() was to
early, so what I did was to set

ViewState["updatingRo w"] = true;

in OnROwUpdated

and start DataBind in the latest phase of page life cycle -
onPreRender, when nested control was already bound programmaticall y to
parent:
protected override void OnPreRender(Eve ntArgs e)
{
base.OnPreRende r(e);

if ((bool)ViewStat e["updatingRo w"])
{
DataList1.DataB ind();
ViewState["updatingRo w"] = false;

}

}
cheers

Apr 29 '06 #2

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

Similar topics

6
3041
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the current_row_key of Grid1... to the objectDataSource2 parameter? (so that the second grid, gets only the information to do with current row of grid1)
0
1706
by: s.gregory | last post by:
My page layout is like this: Page >DataList (databound using ObjectDataSource1 contained in page) >>Items >>>UserControl >>>>GridView (databound using another ObjectDataSource2 contained in UserControl) So I've basically got a GridView (wrapped in a UserControl), that is nested within a DataList. Representing a fairly simple relational data
0
1703
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the OnEditCommand event is raised, I try to do the following: 1. Find the selected datalist item in which the nested datagrid raised the event. (by calling getDataGridReference and returning the DataList's selectedIndex)
1
1381
by: staeri | last post by:
I want to count the rows in a GridView which is nested into a DataList but I can't find the correct syntax for this. Can someone please help me with this and also tell me how to reference a text box control in the nested grid? Regards, Staeri
0
1850
by: H5N1 | last post by:
Hi there My problem is that in when I update GridView row, which is nested into DataList control, I want to refresh also DataList in which the GridView is nested, since after update, trigger in my DB changes some value in it (some Total sum from the GridView column). The GridView, along with its ObjectDataSource is inserted into DataList ItemTemplate.
0
1250
by: ammar_fake | last post by:
Hello there. I need a DataList to render the Gridview by providing one of the DataList values as a query for the underlaying Gridview. This does not work: SelectCommand="select * from projects where emp_id = <%# Eval("EMP_ID") %>"
2
5640
by: needin4mation | last post by:
In a GridView, take for example a delete button. When I click the delete button in my GridView the GridView row is deleted and the GridView rebinds and refreshes the records to show accurately. Problem: I have a GridView that has a select. This select gives a FormView control the data to open. I set the GridView visible to false. I have only my FormView open. This FormView is used to edit, have other DetailsViews that open etc.
7
17319
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work either! Does anyone know how can I make this work? Thanks in advance!
3
9688
by: TimVtoo | last post by:
I'm using ASP VB.net and have a GridView inside a DataList EditItemTemplate. I want to be able to select/edit items in the nested gridview. The GridView is correctly showing child records, but when I click the Edit button I get: The GridView 'gvStagePayments' fired event RowEditing which wasn't handled I have know idia how to create this handler?? Is this possible... I have found some examples (I think) but for c# but struggle to make...
0
9422
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
10206
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...
0
10035
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...
0
9851
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
8863
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
6662
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
5293
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
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
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

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.