Databinding To A Sub Object Declarative Syntax?

Mar 9, 2010

What is the format for databinding to a complex "object"? I have a linq to sql class that has containment, i.e object.containedobject.I want to reference the sub objects fields declarative.So I've tried my MySubField.MyBasicProperty and that did not work, as well as, MySubField_MyBasicProperty.

View 2 Replies


Similar Messages:

Generics - Declarative Syntax For A Collection Of Value Types?

Jul 16, 2010

I know that in ASP.NET (talking about 2.0 here primarily) one can set a property on an object that takes a collection of things (an enumerable type I'm guessing is the trigger) and then reference it declaritivly. For example:

<ObjectDataSource properties="blahblahblah">
<SelectParameters>
<asp:Parameter />
</SelectParameters>
</ObjectDataSource>

It is the <asp:Parameter /> part which is the root of my question. Say I wanted a simpler collection on a type. Say a List<String> or if generics are out, an IntegerCollection or StringCollection. How would I use that declaratively? Is <string value=''> allowed, or can I put raw values into it like <StringCollection>string, string, string</StringCollection> or what?

EDIT:

I feel like I was not clear enough in my question. I understand that ObjectDataSource implements its SelectParameters property as a ParametersCollection, and that one can use that property declaratively (in an ASPX page) to set up Parameter types within that collection. What I'm wondering is if I made something like StringCollection as a property on another control, is there a syntax (in ASPX) for adding strings to that collection? Or would I have to define a wrapping class like how DropDownList takes ListItems to fill its collection?

View 2 Replies

Web Forms :: Using Properties With Databinding Syntax?

Feb 1, 2010

In an ascx control, it's possible to expose properties - let's assume the property name is a string property with a get accessor called DataField. If the ascx control contains a bindable templated control like a FormView and the FormView has a template that uses the two-way databinding syntax, why can't you provide a reference to the property in the call to the Bind method? I see that using the Bind method in a databinding expression causes the page parser to generate a method that is something like the following:

public System.Collections.Specialized.IOrderedDictionary @__ExtractValues__control8(System.Web.UI.Control @__container)

In which, I see the following line:

@__table["Some_Field"] = TextBox1.Text;

Now, this method (@__ExtractValues__control8) is an instance member on the same generated class that defines our DataField property, but when page parser goes to compile the control, I receive the following error:A call to Bind was not well formatted. Please refer to documentation for the correct parameters to Bind. I assume from this that the page parser requires a string literal to be provided, but I don't understand why.

View 8 Replies

C# - How To Bind "OnDataBound" Event Of "DropDownList" In Declarative Syntax To A Static Method In Some Other Class

Jun 16, 2010

How to bind "OnDataBound" event of "DropDownList" in declarative syntax to a static method in some other class ?e.g<asp:DropDownList runat="server" id="d1" OnDataBound="SomeOtherClassThanThisPage.StaticMethod"></asp:DropDownList>

This will give the error, "Page does not contain a definition for SomeOtherClassThanThisPage. it like this or it be done in the Code Behind only ?

View 2 Replies

Forms Data Controls :: DataBinding To Business Object And Retrieving That Object Later?

Jun 17, 2010

Again, I am new to the ASP.NET world, and I come from a Windows Forms background. I'm working with an ObjectDataSource that retrieves a collection of business objects. With the collection, I am going to be binding it to a CheckBoxList and other various controls. The business object that I am using is an Employee.

To get all of the employees, I create an ObjectDataSource and set the "Select" method. I then set the DataSourceID of the CheckBoxList to be that of the ObjectDataSource. When I load the page for the first time, I see all of the employees. Now, the user goes through this page and selects all the employees they want to see information about (by checking the box next to the employee name). Finally, the user hits the button called "Display." Upon postback how do I get a list of those employees? I've tried the following solution, but I'm not sure if it's the best practice in obtaining all those employees again. Here's my solution...

In the CheckBoxList, I set the DataTextField to the Employee's name. I also set the CheckBoxList's DataValueField. This property is a little different. I set this to be a UNIQUE IDENTIFIER, which can distinguish this employee from other employees. Now, when the user hits the button "Display" I use my ObjectDataSource again and MANUALLY call ObjectDataSource.Select(). I cast the returned value as a List<Employee>. Finally, I iterate through all list items in the CheckBoxList...

[Code]....

If the item is selected, I parse through my list of employees that was returned from the bjectDataSource.Select(). I use the item.Value and compare it to each employee's "key." If the key is found, I know that the employee is selected. I put this employee in another list called EmployeesSelected.

Finally, I take EmployeesSelected (which is a List) and set my GridView's .DataSource and call .DataBind() on the GridView.

Is this the "best practice" of re-obtaining the Employees that are selected on my page, or am I making this too complicated?

View 1 Replies

DataSource Controls :: Access Property Of Object As Session Variable As Declarative Datasource Parameter Value

Oct 27, 2010

I am storing a custom "Organisation" object as a session variable. One of the properties of the Organisation object is "OrganisationID" (integer). I have a DataSource that requires a parameter value to run, and I want to use a SessionParameter to populate this. In a previous version, I stored the OrganisationID directly as a session variable. In that case, I could easily access it like this:

[Code]....

However, how do I now access the OrganisationID property of an "Organisation" type session variable (called "Organisation")? I have tried this, which does not seem to work: <asp:SessionParameter Name="OrganisationID" SessionField="Organisation.OrganisationID" Type="Int32" />

View 2 Replies

Databinding Error When Recreating Object?

Apr 26, 2010

Figure there is a simple solution to this problem but I have been unable to find it.I have databinding in an ASP.Net application to a GridView. This gridview is bound to an ObjectDataSource as per standard usage.The problem I have is that one of my bound fields uses the property DataFormatString="{0:C}" and due to the currency format being displayed when an update is attempted and the object recreated I get a error as such "$13.00 is not a valid value for Decimal."Clearly this is a result of the column using a FormatString and then attempting to bind it back to a decimal property I have in my object called UnitPrice.I am assuming there is some markup I can set that can specify how the value is translated back?For anyone curious the solution ended up looking like this...

<asp:TemplateField>
<HeaderTemplate>
UnitPrice

[code]...

View 1 Replies

Forms Data Controls :: Trying To Use Dynamic Object In A Databinding Tag

Sep 18, 2010

im trying to use dynamic object in a databinding tag , it gives me error that the property does not exists even though i can see all the properties there in the vs debug mode

here is what im trying to do:

C#:

my method signature:

public static dynamic MyMethod()

ASPX:

in control itemtemplate:

<%# MyMethod().SomeProperty %>

if also trite the other way:

C#:

public static object MyMethod()

ASPX:

<%# ((dymanic)MyMethod() ).SomeProperty%>

But i dont know why it cant resolve the properties , even though i can see them when the databinder control throws an exception (its working fine outside the databinder tag (ie normal aspx tags <% %>)

View 1 Replies

ADO.NET :: Simple Databinding With LINQ Causing Object Reference Not Set?

Aug 15, 2010

I have a user control with a datalist. I just want to do some simple binding but keep getting an object reference not set to an instance of an object error. The following is the code, I am sure I am just missing something simple:

Dim dc As Forms.DataClassesDataContext = New Forms.DataClassesDataContext
Dim formQuery = From fq In dc.v_form_questions _
Where fq.FormTypeID = FormTypeID _

[code]...

When I debug, I see values for the formQuery; I am also able to loop through the formQuery and response.write a field out, however every time I try to bind it to a databound control, I get the Object reference not set to an instance of an object error.I initally was using a simple LinqDataSource object, but needed to set the where parameter to the FormTypeID property of this usercontrol. I had a Where condition defined on Page Init, but started getting the object reference error.

View 1 Replies

ObjectDataSource Databinding: Getting Object Properties By Select Method Call - How To Access Value

Feb 22, 2010

I am using an ObjectDataSource control to call a MapInfo object. This object has two properties:

public IList Visits
public int TotalAvailable

The select method returns an IList but the TotalAvailable property is also populated. I have set the TypeName in the ObjectDataSource to the MapInfo object but because the Select method only returns the IList I don't have access to the TotalAvailable.

[code]....

Is there any way to access this value. I know it is being populated in the MapInfo object but all that gets returned from the Select method is the IList

View 2 Replies

Databinding - Binding Int Values From Server Side Error / Cannot Create An Object

Feb 13, 2010

Quick question here. I'm sure it's possilbe, just can't get it to work.

I've got a gridview. In have a gridview. The gridview is bound to a list of my custom class. The class exposes a link to an image as well as the image's height and width. I have a Image Control in the gridview. I've bound the Image Url to the correct property. Now, I'd like to bind the height and width properties as well. But everytime I do that I get the following error:


Cannot create an object of type 'System.Web.UI.WebControls.Unit' from its string representation '"<%#Bind("GetImageHeight()")%' for the 'Height' property.

Here is an example of the tag:

<asp:Image runat="server" ID="imgProduct" ImageUrl='<%#Bind("ImageUrl")%>'
Height="<%#Bind("GetImageHeight()")%>" Width="<%#Bind("GetImageWidth()")%>">
</asp:Image>

[code]....

View 3 Replies

Syntax To Change The Value Of A Cached Object Property?

Jun 6, 2010

In an ASP.NET 3.5 VB web app, I successfully manage to cache an object containing several personal details such as name, address, etc. One of the items is CreditNum which I'd like to change in the cache on the fly. Is there a way to access this directly in the cache or do I have to destroy and rebuild the whole object just to change the value of objMemberDetails.CreditNum?The cache is set using:

Public Shared Sub CacheSet(ByVal key As String, ByVal value As Object)
Dim userID As String = HttpContext.Current.User.Identity.Name
HttpContext.Current.Cache(key & "_" & userID) = value
End Sub

View 1 Replies

Is It Possible To Declarative Pass Properties

Apr 19, 2010

is it possible to declarative pass properties (in my case property of DataContext type) to User Control without DataBinding.

Now code looks like this:

[code].....

View 4 Replies

Access :: Syntax Error (missing Operator) In Query Expression / Get Conflict With CommandText Syntax

Aug 8, 2010

I'm having problem in inserting text from a textbox in which user write or copy some text which may contain special characters ( " , . ) etc. If there is any special character it get conflict with CommandText Syntax and generates error in inserting. I want to insert all these characters. How could i do it?

Code:

[code]....

View 1 Replies

Why Can't Use C# Syntax In Inherits Attribute For A Closed Generic But CLR Syntax Is Fine

Jan 15, 2011

The following CLR syntax works fine in my aspx page:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="Website.MyBasePage`1[HomePageViewModel]" %>

But this C# syntax does not:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="Website.MyBasePage<HomePageViewModel>" %>

Note, I am not using ASP.NET MVC, but this works fine if using System.Web.Mvc.ViewPage<> from ASP.NET MVC.
My MyBasePage looks like this:

public class MyBasePage<TModel> : Page where TModel : class {
public TModel Model
{
get { return (TModel)HttpContext.Current.Items["model"]; }
}
}

View 1 Replies

Web Forms :: User Control With Declarative Paramaters?

May 19, 2010

Is there anyway to pass parameters to a custom user control using declarative paramters.E.g.

<MyUserContrl id = "" runat="">
<PARAM Title = ""/>
<PARAM SelectTable="" />

[code]...

View 6 Replies

C# - Interdependent Dropdowns In Gridview Using Declarative Programming?

Feb 14, 2010

I have a binded dropdown control in the gridview under edittemplate. Now i wanted to populate the second dropdown in the same gridview based on the first selection. I dont have options but use the gridview & declarative coding.

Also i am using the objectdatasource here.

View 1 Replies

MVC :: Razor: Referencing Declarative Html Helpers?

Dec 15, 2010

I'm trying to write a simple declarative html helper: [Code]....

The helper works fine if I embed it into the page I want to use it on. But if I move it to a separate .cshtml file and place that file in the ~/Views/Helpers directory, my view can't be compiled anymore because the helper is not found.According to Scott Gu's blog article on Razor it should work.

The only workaround I have found so far is placing the Html helper in App_Code and Referencing it as @[MYHTMLHELPERFILENAME].Echo(...) . This works but is a bit messy since I don't want to repeat the name of my extension method (Echo.Echo("inputstring"), nor do I want to put all of my html helpers into one single file (something like MyHtmlHelpers.cshtml).It certainly isn't what Scott announced either, so I guess I must be doing something wrong.

View 4 Replies

MVC :: 3 RC2 - Convert ASPX Syntax To Razor Syntax For Asp:Hyperlink?

Dec 15, 2010

For reporting we used report RDLCs and displayed using an ASPX form. We implemented using the route as shown below. This resulted in forcing us to use the page route below and also to use the hyperlink instead of the normal Action Link. The question is how do we convert the asp:hyperlink ASPX syntax to Razor syntax.

//Custom route for reports routes.MapPageRoute( "ReportRoute", // Route name "Reports/{reportname}", // URL "~/Reports/{reportname}.aspx" // File );
<li><asp:HyperLink ID="hypReport" runat="server" NavigateUrl="<%&#36;RouteUrl:routename=ReportRoute,reportname=StaffRpt%>">Staff Report</asp:HyperLink></li>

View 2 Replies

MVC.NET Tag For Checking Roles (equivalent Of Declarative Attribute PrincipalPermission)?

Apr 5, 2010

I use declarative roles in my MVC.NET controllers and I have a custom membership & roles provider.This works fine:

[Authorize(Roles = "ADMIN")]

Also, I have a base MVC.NET CustomController class that all controllers derive from, and it has a "currentUser" property that is auto-fetched from the session on demand, so all controller code just refers to "currentUser" and doesn't worry about sessions, httpcontext, etc. I've implemented the membership provider properly, as it works with other parts of the framework that just deals with providers, but until now I had not tried to access the "User" principal from a view.What is the simplest syntax for check roles in a view page? I know I can use a helper to generate a partial view but I don't want that here, I want to explicitly wrap some sections of a page in some role checks.Something like this:

<% if(currentUser.IsInRole("ADMIN") { %>
...
<% } %>

View 1 Replies

Web Forms :: How To Add Multiple Controls To Declarative Catalog Part By Default

Feb 11, 2011

i want to add control 1, control 2 etc.. by default in Declarative Catalog Part

and using following code

[Code]....

but it only displays last item in it

any one guide me what mistake am i doing or what is the solution to my problem?

actually i want to give default 4-5 webparts options so that user could add it to page

View 1 Replies

Forms Data Controls :: Exception Handling With Declarative GridView?

Jan 17, 2011

I'm using Visual Web Developer 2010 Express with C# 2008 and .NET v4.0 to create a website which will have a database application. The database is SQL Server 2008.

I would have searched this forum for similar questions but I can't find a 'Search this forum' option! So I apologise if someone has already answered this.

I've successfully displayed rows from my database by dragging and dropping a GridView and an SQLDataSource control onto my page, and by using the Connection Wizard to set them up. But when I go live with my new pages, I will have to put my database in a different folder, and until I edit the web.config connection string to point at it I expect to get an exception.

I understand that when you try and open a database connection, this is the perfect place to use try...catch exception handling. But all the examples I can find put the try-catch code on the Button_Click event! Where should I put it? I can' t find anywhere where my controls actually attempt to open the database!

I know I could rip out what I've done and write all the code to connect to the database myself, but as I've finally got everything to work I would prefer to make the change as small as possible. So, what is the minimum change I have to make to add exception handling to my datasource/ gridview?

View 6 Replies

SQL Server :: EXEC 17P_Comose Will Give Incorrect Syntax Error - Incorrect Syntax Near '17'

Sep 15, 2010

I am working with a sql server database with about 50 stored procedures. The database and stored procedureswere not created by me. The stored procedures all begin with a number in their name.

Example: 17P_Comsetter

The problem I am having is that if I try and execute the stored procedure at the command line in Query Analyzer,the query analyzer appears not to like that the stored procedure begins with a number. For example:

If I try an run the stored procedure as follows:

EXEC 17P_Comsetter

Then I get the following error message:

Msg 102, ..... Incorrect Syntax near '17'

I am using SQL server 2005. Does anyone know why I am getting this error message?

View 1 Replies

ADO.NET :: Not Working Showing Syntax Error Syntax Error:operand Is Missing?

Mar 25, 2011

DataRow[] filterRows = ds.Tables[0].Select("Running Status= case State when 'True' then 'Running' When 'False' Then 'Stoped' end Where Active='1' and State='1'");

this is not working showing syntax error syntax error:operand is missing

View 3 Replies

Web Forms :: Declarative #Bind Doesn't Bind In Update Command

Sep 6, 2010

I have a bunch of controls like the following in the EditItemTemplate of a ListView, with LINQDataSource:

[Code]....

I'm curious to know why the database won't update on the click of the Update button:

[Code]....

According to all I've read, the above code should be sufficient. Since CommandName is set to Update, it would seem that no code-behind is necessary.

View 20 Replies







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