Asp.net - Pass An Object Into A UserControl In A Repeater?

Jul 24, 2009

I want to wrap up a chunk of HTML render logic in a User Control. Then I want to pass a custom product object (title, thumbnail, id, etc.) to the UserControl that it can use when it renders. Ideally I want to use this in a repeater (or for loop) and pass the current custom product object into the UC.Every example I've seen has been passing through strings on the UC tag but thats not really want I want to do as it means I'll have references everywhere that need updating should we add a new field that needs rendering.

.Net 1 using VB.net (not my first choice for .net so go easy)HTML example to get us going, this would be in the .ascx page:

<div>
<h3><%= myProd.title %></h3>
<img src="<%= myProd.thumbnail %>" />
<p>

[code]....

Yet in my ascs page I get:"Object reference not set to an instance of an object"

Line 1: <%@ Control Language="vb" AutoEventWireup="false" Codebehind="ProductRender.ascx.vb" Inherits="MyApp.ProductRender" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
Line 2: <h3>
Line 3: <%= myProd.title %>
Line 4: </h3>

View 2 Replies


ADVERTISEMENT

Asp.net - Nested Repeater Error: Object Reference Not Set To An Instance Of An Object?

Jul 28, 2011

I am taking some code that I have used for a nested listview before and trying to make it work with a nested Repeater but I am getting an error.

System.NullReferenceException: Object reference not set to an instance of an object.

.aspx
<asp:Repeater ID="reMainNav" runat="server">
<HeaderTemplate><ul></HeaderTemplate>[code].....

View 1 Replies

Forms :: Pass UserControl As An Argument?

Sep 8, 2010

I've got several user controls and every time I add them, I post this

Dim uc As New ucTemplates ' 'ucTemplates' is the name of the actual user contrll
gbControls.Controls.Clear()
gbControls.Controls.Add(uc)

So, I'd like to create a sub that does the same thing, passing the usercontrol as an argument

Private Sub AddUC(myControl as UserControl)
gbControls.Controls.Clear()
gbControls.Controls.Add(myControl)
End Sub

But - when I try:
addUC(ucTemplates)

I get an error that ucTemplates is a type and cannot be used as an expression
I can get it working if I add the Dim uc As New before the addUC - but I'd rather have it so I only repeat one line, not 2

View 1 Replies

Pass Data From View To UserControl In ASP.NET MVC?

Mar 24, 2010

Say I want to do the simplest of the data passing as follows [code]...

What I want to do is to pass the variable i as the parameter to the UserControl so that it displays the number inside a, say, bordered div.

View 2 Replies

Pass A Listbox Selecteditem In Usercontrol To Parent Form?

Oct 19, 2010

I have a user control which contains several buttons and a listbox. Clicking a buttondetermines what items are in the listbox. When a user clicks an item in the listbox I want the selecteditem passed to the parent form.

View 6 Replies

Function - Pass Object Versus Reference Object In Parent?

Dec 1, 2011

I am working on a application that has quite a few functions involved and have been thinking of the following: If I have a function that has a few paramaters, is it more efficient to pass the objects to the function(Example 1) or reference the objects in the parent(Example 2)? Does it matter if the objects are large or not?

Example:

Class mainform
Public myGenericList As New List(Of String)
Public myDatarowArray() As DataRow

[Code].....

View 6 Replies

Asp.net - Access A Gridview Inside A Repeater Which Is Inside A Repeater (Nested Repeater)?

Apr 11, 2012

How can I access rep_DataSimilarToBacthid ? I need to bind the GridView and call GridView RowDataBound or InitializeRow

[Code]...

I am using VB.Net with Framework Version 2.0.

View 1 Replies

Asp.net - Nested Repeater Show Data That Matches Parent Repeater

Mar 15, 2011

I am using a repeater to build a custom table. However, I can't figure out how to make the table show subtotal if the next rows tour does not match the previous rows.

Something similar to that.

row1 tour1
row2 tour 1
tour1 subtotal

[Code].....

but this shows all the data in the nested repeater not the ones that match the parentrepeater fields for example tour,theme,dep7 should match in the child repeater

View 1 Replies

Rebind Repeater Using Next / Previous Buttons In The ItemTemplate Of The Same Repeater?

Mar 27, 2009

I have a parent repeater with nested repeaters.My problem is I am trying to use 'Next' and 'Previous' buttons to rebind my repeater (rptTabContent) and thus the inner repeaters also, but when I try to manipulate the state of these links during the ItemCommand event they are overwritten by the bind.

View 1 Replies

Asp.net - DragDrop Event Not Firing On Object Inside Usercontrol (but DragEnter Does)

Feb 12, 2012

Well the title pretty well describes my problem. Here is a little bit more detailed description of my problem: I am building an application with a TabControl, which I populate at execution time with TabPages. In my first version of the code, these TabPages were filled with a children ListView. The ListView was also created in code, using AddHandlers to link it to the DragEnter and DragDrop routines. Everything worked very well... Now as I need some other controls on every TabPage, instead of creating every single control in code, I have created a UserControl containing a ListView and a few Buttons, which I instantiate for every new TabPage. The problem now is that the DragDrop event is not raised anymore

[Code]...

View 1 Replies

Pass Usercontrol Controls Or Form Controls?

May 11, 2009

I created a class that can take either usercontrol.controls or form.controls as a parameter,how can i pass either to that class? as a property or how?

View 4 Replies

Asp.net - How To Pass An ID From Parent ListView To A Child Repeater Inside The Parent ListView

Oct 12, 2011

I have a listview "CategoriesList" and i have a repeater "NewsRepeater" inside the listview "CategoriesList"

<asp:ListView ID="CategoriesList" runat="server" DataKeyNames="CatID" DataSourceID="CategoriesListODS"
EnableModelValidation="True">

[Code]....

how to pass the catID from the listview and make it as SelectParameters in ObjectDataSource "NewsRepeaterODS"?

View 1 Replies

How To Pass Object As Sub

Jan 20, 2012

This code copose from Class including tow sub first sub to insert data in DB Ms access- second code: to check if there is same number of Tel if there is not same number will excute the first code insert, if there is same number of Tel it will show messagebox the problem that I faced is by how to pass object(InsertData) from CheckN sub. It showed me error : Expression is not a method

[Code3]...

View 1 Replies

How To Get Name Of Object And Pass Parameters

Jan 31, 2012

For example if I have a function call like below
Function callingMe()
Exit Function

And my Function call is like below
SomeObj.callingMe('1','2','3','4','5') // Variable number of arguments
Inside callingMe() function, I want to know arguments passed i.e 1,2,3,4,5 and the Object i.e SomeObj in above case.

View 2 Replies

Make An Object Not Pass Through Another?

Apr 5, 2012

I am making a simple maze game that you use the arrows keys to navigate. I completed the movement part of it, but now i'm having trouble with the walls. How can you make an object not pass through another and how to tell the program what to do when a object gets to a defined place(the finish)

View 4 Replies

Object Must Pass Itself As A Parameter?

Sep 10, 2011

I have various shape objects, and I want each unique shape to implement a saveToDB method that simply calls a DB object that implements a Save method with an object as its input paramter. This DB.Save method will be a long case function that implements the proper SQL commands based on the type of attributes possessed by the input parameter object.how do I implement the SaveToDB method in my Shape class? Is it something like this:

Function Shape.SaveToDB
DB.Save(Me)
End Function

The goal here is to let each shape save itself without it knowing anything about database operations; I want to isolate db-specific information in my intermediary DB object, so the DB object will have to figure out what type of object wants to be saved into the SQL database and then execute whatever SQL instructions are needed. And then if I override the SaveToDB method in each shape subclass, I can avoid the case statement entirely, replacing it with a series of unique methods such as db.SaveCircle (ob), db.SaveSquare (ob), etc., sincle the caller already knows what it is.

View 4 Replies

Pass A Function As An Object Instead Of It?

Dec 20, 2011

I'm trying to give a default value to the register property method. This required a function, but passed as an object(delegate?).[code]....

I want to call that registerproperty method, but I don't know how I can do that in VB.net. I just need to pass along a new Person object and I thought this was the way to go[code]....

View 3 Replies

Pass Data Out Of An Object?

Dec 17, 2010

I have this [code]...

1. Create a global SQL instance and call .Write from within .ReadData

2. Create a new SQL instance within .ReadData and call .Write

3. Pass the data back to the code above and call .Write from the main code i.e. [code]...

View 1 Replies

Pass Object Between Asp.net Applications?

Jan 6, 2012

We have a few applications that will be passing a token object around and I wanted to get an idea about the best approach at doing this.

For starters, this token object is somewhat simple. It would have about 5 properties or so.

Would we create a WCF app and reference it through a datacontract?What about serializing it and sending it through an http post? (each app have a referenced dll of the object)Querystring? (I truly don't think this would be good, but put it up nonetheless)?

View 2 Replies

Pass Out An Object Array In .NET?

Mar 25, 2011

I'm writing a wrapper class to expose a subset of the functionality of a .NET FTP library edtftpne from Enterprise Distributed Technologies.

When you call the edtftp's GetFileInfos method you get an array of FTPFile objects returned. I'm able to iterate through these but I don't know how to pass them on as a new and different object array containing only Name and Size for each file. Here's the code I have. Sorry it's a little confusing because I have my own class named FTPFile and the .NET library I'm using also has a class named FTPFile. I'm using both of them here. I should probably change the name of my class just to avoid confusion:

Public Function GetFileList() As FTPFile() Implements IFTP.GetFileList
Dim ftpfiles() As EnterpriseDT.Net.Ftp.FTPFile
ftpfiles = fCon.GetFileInfos 'Fill object array

[Code]....

I'd just pass on the object array that I'm getting from the GetFileInfos method but COM clients won't have access to the class/object EnterpriseDT.Net.Ftp.FTPFile without me rewriting it, I'm assuming.

View 1 Replies

Call A Method And Pass In An Object?

Apr 21, 2012

I have a method called ADD in a class that connects to a database. The database class name is XDB. I also have an object named XXX in it's own separate class with properties.One of the instructions for the Button named ADD click event is:

'Call Add method passing in the XXX object

So this is how I coded:

'declare a variable X as an object instance of XXX
Dim X As New XXX[code].....

I know it's wrong since it doesn't add the XXX and the form doesn't close but I don't know what I'm doing wrong.

View 6 Replies

Calling A Sub And Pass In Parent Object?

Jul 6, 2009

I have a statement that will call a Sub.

Charts(CurChartNo) = Server.CreateObject("ChartFX.WebServer")
Call InitChart()

Inside this sub, I will assign values to the properties of the Charts object that is

Public Sub InitChart()
Charts(CurChartNo).RGB2Dbk = &HC0FFFF&
Charts(CurChartNo).Chart3D = False

[code]....

But the Charts is not recognized in the Sub. This is current program under ASP, I am converting to ASP.Net.

View 3 Replies

Correct Way To Pass The Graphics Object?

Oct 2, 2009

When I do my form_paint event, I have quite a lot to redraw, so I'm breaking into into severals subs to make it easier to read. I'm passing the 'e' variable into my subs as shown below, is this correct?

Private Sub frmMain_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
DrawMap(e)
End Sub
Private Sub DrawMap(ByVal e As System.Windows.Forms.PaintEventArgs)
End Sub

Am I right in copying that whole 'e as system.windows....' etc line from the form_paint details into my subs details?Just to clarify, the sub will draw directly onto the form.

View 3 Replies

Dynamically Pass Values To An Object?

Mar 28, 2011

How can I do this:

Dim oMyObject As New MyObject
oMyObject.DoSomething("Parameter1","Parameter2")

The "DoSomething" and the two parameters are dynamically provided from another script. They are stored in a string object in this script: sAction & sParameters. My question is how can I dynamically pass the "sAction" to the object oMyObject.For example oMyObject.sAction (where sAction should be the value stored in the sAction string). The example will probably not work. Is there a way to do this? The idea behind is to avoid having to write each function hardcoded, like:

If sAction = "DoSomething" then
oMyObject.DoSomething(sParameters)
ElseIf sAction = "AnotherThing" then

[code]....

View 5 Replies

Pass A String Return An Object?

Feb 12, 2011

I 'm new to programming and to vb. So my question could be from misconception about what can i do. How can i pass a string to a "procedure" and get in return a object whith the same name as the string?

View 8 Replies

Pass An Object Type To A Class?

Jun 18, 2009

I create a object type entity in the main function and would like to pass it to a separate class, do some calculation, and then pass the result back to the main function. But I keep getting errors, can someone point me where I did wrong? It's in windows application[code]...

View 2 Replies

Pass Object To Function Using CodeDom?

Jun 27, 2010

How do you pass a control (say a textbox) to a function as a parameter in compiled assembly using CodeDom? I've tried passing through the args in the Invoke method but it doesn't work.[code]...

View 6 Replies

Pass Reference Object From One Form To Another?

Apr 29, 2011

I have maintain a common data table for 3 forms.[code]...

View 5 Replies

Pass Variables To A COM Object From Application?

Aug 10, 2010

I am writting a VB .net (3.5) applivcation which references a COM object. I can call methods on the COM object fine provided that they don't require any variables to be passed. I have been told that you can only pass a maximum of one varaible to a COM object, I really don't believe that it true

for example
objsession.connect()
works fine
but

[Code]...

View 6 Replies

VS 2005 Pass My.Settings Object To A Sub?

Dec 17, 2009

I have a sub that I want to receive a My.Settings object. I don't know, though, which kind of object to use in the declare line of the sub. For example:[code]

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved