.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Nested Databinding of Object Accessing Parent Property

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

I'm wondering if there's a way to access a parent properties in databinding, of if I am going to have to re-write some objects to pass down data.

Pseudo Example:

Cars Generic of Car
Car Properties: Id, Makes

Makes Generic of Make
Make Properties: Id, Name, Models

Models Generic of Model
Model Properties: Id, Name


repeater (datasource = cars)
---repeater (datasource = Makes)
..........<%# Eval("Name") %>
------repeater (datasource = Models)
..................<%# Eval("Name") %>  <%# Eval("??? Make.Id ???") %>

So in the nested repeaters, I somehow need to access the parent's Id. In this example the Make's Id.
Is this possible?

Or do I need to add Property to child objects that refer to the parents?


View Complete Post

More Related Resource Links

Accessing a public property of a nested user control in a master page from a pages' user control

Hi  I've got a web site that has a master page and that master page (mpMaster that has a user control (ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page and on this page I have another user control (ucPageControl), I need to  find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all? Many thanks Ed

DataBinding not updating underlying business object when changing control property from code


I have a custom data form control that in code generates databindings between the selected custom business object (LLBL) and the various controls on the screen. Everything works in that I set the DataContext to the selected business object and the data appears in the GUI. If the user changes anything on screen, the data is getting updated into the business object.

However, now I have some custom logic that when the user presses a button I need to update some fields. Currently I'm setting this data directly into the controls, setting the new value into the property that is bound. However, the data is not getting pushed back into the business object.  I had this same issue building WinForm apps in that databinding only fired if the user was in the control and left it.

Does the same thing apply to WPF? How can I get ANY change on say a TextBox's Text property whether via user interaction or from C# code to push that value into the bound business object property?


Nested DataGrid - Accessing parent selected row from child in MVVM

Hi All,

I have a nested datagrid. The child datagrid is inside the RowDetailsTemplate.
I have expander and collapse button to open the child datagrid. When i select the expander/collapse button, the row of the parent datgrid gets selected and the child datagrid is loaded with data. Next, i select the child datagrid row. So the problem is when i am selecting the child datagridrow, the parent datagrid row selection should be deselected.

This needs to be achieved in MVVM

Please help.

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

Object or Property is not supported in IE8 - javascript error



I am using following code line in my web app through external javascript file.






both these methods are working fine in IE6 but failing in IE8 with a error: "Object or Property is not supported".


any solution would be appreciated!



Microsoft JScript runtime error: 'Parent' is null or not an object


Hi friends,

        I got This Error : Microsoft JScript runtime error: 'Parent' is null or not an object

 In runtime,after  click on the check box, It Show "Microsoft JScript runtime error: 'Parent' is null or not an object"

<script language ="javascript" type ="text/javascript" >
        function SelectAllCheckboxesSpecific(spanChk)
           var IsChecked = spanChk.checked;
           var items=0;
           var Chk = spanChk;
              Parent = document.getElementById('gvUsers');          
              var items = Parent.getElementsByTagName('input');                         
              for(var i=0;i<items.length;i++)
                  if(items[i].id != Chk && items[i].type=="checkbox")
                      if(items[i].checked!= IsChecked)

please verify it. 

Display a nested child ListView on PostBack while using DataPager on parent ListView


Hello ASP.NET community,

I am having trouble finding how to solve the following issue :

I am using nested listviews to display Sales and Sales details.

The main ListView displays General Information about Sales and the child ListView displays the detailed information about one sale. the child listview is shown only when the user clicks on a link (see included code, DataBind is made on PageLoad) :

ASPX Markup Code :

<asp:listview id="lvSales" runat="server" onitemdatabound="lvSales_ItemDataBound">
<table cellspacing="0" border="1" width="250" style="border-collapse:collapse;">
<tr runat="server" id="headerRow">
<th scope="col" style="width:30px;"></th>
<th scope="col">SaleNumber</th>
<tr id="itemPlaceHolder" runat="server" enableviewstate="true"/>
<tr id="row" runat="server">
<td style="text-align:center;"><asp:button id="btnShowHideDetails" runat="server" oncommand=&qu

Getting "wrong" data out of a microsoft.sqlserver.management.smo.database object property (using pow

My problem:I do something like this:$dbsvr = new-object microsoft.sqlserver.management.smo.server "servername"$dbsvr.databases | ft name,size -autosizeWhen i run this from two different PC's i get database sizes that are all the same (5.25 mb), the size of the first database listed - which is master.I started to try out a few things, and found out that when i run the same command from one of our servers it returns the correct sizes...Anyone have any idea if this a SMO issue, or maybe some package software version issue...- or what?

Error "Object reference not set" when I try to set a Navigation Property

I'm using Entity Framework. The following code throws a runtime error "System.NullReferenceException: Object reference not set to an instance of an object." The line before the error, it looks like newControl is in fact instantiated.My model has a Control entity and a ControlType entity. Control includes the Navigation Property "ControlType." I'm trying to set ControlType.Type = 2.SurveyFormControlsModel.Control newControl = new SurveyFormControlsModel.Control(); newControl = CreateControl(childTokenName, ControlTypeEnum.TextBox); newControl.ControlType.Type = 2; // <<--ERROR HERE context.Controls.AddObject(newControl);                                SurveyFormControlsModel.Control newControl = new SurveyFormControlsModel.Control();                                 if (listItems.Count == 0)                                 {                                     newControl = CreateControl(childTokenName, ControlTypeEnum.TextBox);                    &

How to assign data from 1 DataReader into Parent/Child object??

Hi I have a parent & child table. Parent - User UserID UserName Status 1 Shallin A 2 How A   Child - UserAccess UserID Country Default 1 US 0 1 UK 0 1 MY 1 2 SG 0 2 HK 0 2 MY 1   I also have parent & child object class.       I would like to use 1 C# function and 1 SP to handle the retrieve portion but I have 1 problem. I'm not sure how to assign the value from Reader to the object.   I do something like this but I only get 1 country which is the last country. if (dr.HasRows) {     while (dr.Read())     {         User objUser = new User();         objUser.UserID = dr["User_ID"].ToString().Trim();         objUser.UserName = dr["UserName"].ToString().Trim();         objUser.UserStatus = dr["Status"].ToString().Trim();         UserAccess objUserAccess = new UserAccess();         objUserAccess.Country = dr["Country"].ToString().Trim();         objUserAccess.Default = dr["Default"].ToString().Trim();         objUser.UserAccessCollection = new UserA

Object does not support this property or method....

This is a pretty straightforward piece of code. Why am I getting this error on line 5 char1?<script type="text/javascript"> function resubmit() { var recip = document.getElementById("web_recip"); var ind=recip.indexof("?resubmit"); if (ind>0){ recip=recip.replace("?resubmit",""); var resub=document.getElementById("resub"); resub.value="Y"; } } </script>  

XML databinding - accessing attributes of ParentNode from childNode in XAML

Hi All, I would like to get the ParentNode of a given childNode for the xml databinding in XAML. So what should I do ??? For instance: [XML] <Answer           Margin="40,1,1,1"           TabIndex="4"           Name="Answer"           DataType="bool"           Value="N">           <Option             Name="Y"             DisplayText="Yes"             MaxLength="1"             Width="20" />           <Option             Name="N"             DisplayText="No"             MaxLength="1"             Width="

How to find specific nested object type in Gridview

Dears, I have a gridview with a nested placeholder in each rows. I nested some checkboxes in each placeholders in each rows dynamically, so their ServerIDs are not the same (I dont want to use nested gridview). at the end in a button event I want to count checked checkboxes in gridview while I can not use findcontrol() method in each rows to find checkboxes due to their different ServerIDs. How can I do this?

Issue accessing textbox controls nested within a DetailsView within an UpdatePanel

I have a couple of textboxes nested with a detailsview, within an updatepanel.  When I try and access them from the code behind, it returns a null value as if they don't exist.  Can't figure out why that would be.ASPX code is: <asp:UpdatePanel ID="upSpecificShout" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" > <ContentTemplate> <asp:DetailsView ID="dvSingleShout" DataSourceID="sdsSingleShout" runat="server" AutoGenerateRows="false" OnDataBound="SetDVIcons" HeaderStyle-CssClass="noDisplay" > <EmptyDataTemplate> <p class="Watermark"> The panel on the left shows a list of everything you've shouted. (Your replies to other shouts are highlighted in blue/green.) </p> <p class="Watermark"> This right hand panel will show specific shouts with a list of replies etc.. Just do a little click on a shout title to display more detail here. </p> <p class="Watermark">

Accessing master formview data from a nested detail formview?

Hi all, I would like to ask if it is possible to access data on a master FormView from a nested detail FormView. I have a main form (master) with several tabs (detail) and would like to display a label with text from main form that is hidden by the tab at the moment of editting. My asp page looks like this.<asp:FormView ID="fvwCustomer" runat="server" DataSourceID="dsCustomer" DefaultMode="Edit" DataKeyNames="CustomerID"> <EditItemTemplate> <asp:TextBox ID="CompanyTextBox" runat="server" Text='<%# Bind("Company") %>' /> <asp:FormView ID="fvwContactPerson" runat="server" DataSourceID="dsContactPerson" DefaultMode="Edit" DataKeyNames="ContactPersonID"> <EditItemTemplate> <%-- I need to get the value Company from dsCustomer --%> <asp:Label ID="CompanyTextLabel" runat="server" Text='<%# Eval("Company") %>' /> </EditItemTemplate> </asp:FormView> </EditItemTemplate> </asp:FormView>   Is it possible to get the value of the label CompanyTextLabel from CompanyTextBox using just ASP.NET expressions or something similar without writing c# code in

Databinding to a property of a child entity.

<asp:Label ID="Label4" runat="server"                         Text='<%# Bind("EmployeeIdSource.EmployeeName") %>'></asp:Label>Is this kind of databinding permitted?

Nested Gridview and databinding

protected void grdClientPayments_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { GridView gv = (GridView)e.Row.FindControl("grdPayments"); SqlDataSource dbSrc = new SqlDataSource(); dbSrc.ConnectionString = NFMData.DB.GetDBConn(); dbSrc.SelectCommand = "SELECT APR.PaymentID, APR.AdID, PaymentAmount, PaymentDate, CheckNo, APR.Comments " + "FROM AdPaymentReceived APR " + "LEFT OUTER JOIN ISRPayment_Payments IPP ON IPP.PaymentID = APR.PaymentID " + "WHERE ISNULL(IPP.Amount,0) <= 0 AND APR.AdID = " + ((DataRowView)e.Row.DataItem)["AdID"].ToString(); gv.DataSource = dbSrc; gv.DataBind(); foreach (GridViewRow gvRow in gv.Rows) { if (gvRow.RowType == DataControlRowType.DataRow) { decimal PaymentAmount = (decimal)((DataRowView)gvRow.DataItem)["PaymentAmount"]; } } }   So basically what I'm trying to do is do some calculation on the rows in the sub-grid based on some values in the main grid.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend