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

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

Early Late binding & Polymorphism question

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
Hi,I read this online about early & late binding.. I don't understand (the example below) how it is, can anyone explain why?Early binding:: Properties and method can be identified by compile time.Example: dim rs as recordsetLate binnding: Properties and method can be identified by Run time.Example: dim obj as classnameset obj=new classnamePolymorphism:Also, why the reason they are said Method overloading & OverridingExample of Compile Time Polymorphism: Method OverloadingExample of Run Time Polymorphism: Method OverridingCan anyone explain the logic behind these two? Thanks in advanceThanks

View Complete Post

More Related Resource Links

Simple data binding question

Newbie binding question here: is it possible to bind a control in XAML to a StaticResource by passing in the key via a data structure? Basically something like this: <TextBlock Text="{Binding ImageKey}" /> <Image Source="{StaticResource ResourceKey={Binding ImageKey}}" /> <-- doesn't work   The TextBlock binding on the first line works correctly, it extracts the key of the StaticResource from my data structure and displays it correctly. What I'm trying to do is get the Image control to bind to the StaticResource with that name (which happens to be a BitmapImage).      

Need help with late binding on bindingsource field

This is an error that popped up with after setting option strict to on   option strict disallows late binding   The error is on the field in red If customer_data_reader("CustID") = (customer_bindingsource.Current("CustID") Then          i was looking at this but i cannot find what type this is exactly   If CStr(customer_data_reader("CustID")) = Ctype(customer_bindingsource.Current("CustID"), ????????) Then      It is a field, but how would i set the type for this? Or do i need to do something different?   Thanks Jeff

Another basic Data Binding question

3 days ago (thanks to Olaf) I was able to make progress with binding a data collection to a DataGrid. Since then I have searched the web in vain for a VB example to enable me to switch off the DataGrid AutoGenerateColumns and enter my own columns and appropriate Paths to the Collection’s properties.   The following code works fine but I can’t work out how to enter my own individual columns etc. Can anyone give me the syntax for an example of one column please?   Why is it so difficult to find VB examples of WPF demos etc? (Nearly everything is in C#.)   I have some experience in Access VB so have picked VB in trying to use WPF. I would be grateful for any links to VB WPF resources. Option Explicit On Option Strict On Imports System.Collections.ObjectModel Partial Public Class DataGrid_FilledFromCodeBehind Private _ocEng As ObservableCollection(Of EnPlayer) Public Property EngSqd() As ObservableCollection(Of EnPlayer) Get Return _ocEng End Get Set(ByVal value As ObservableCollection(Of EnPlayer)) _ocEng = value End Set End Property Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded _ocEng = New ObservableCollection(Of EnPlayer)() For i = 0 To 4 EngSqd.Add(New EnPlayer(ref(i), names(i), ages(i), bat(i))) Next Me.DataCon

Binding Question How does one set datacontext to same class in XAML?


I have a usercontrol with one button in it.  I want to set the text via a property getter setter using the INotifyPropertyChanged interface in code behind.  I can get it to work if I set the DATACONTEXT in code behind in the CTOR like this : DataContext = this;  Everything works perfect. 

But here's the problem.  If I try to do this in xaml by defining an XMLNS which points to the folder this usercontrol is in, and then attempt to reference it as a resouce like this <local:XXXXXX  <-------The XXXX which is the class name of this control can't be found?  Is that wierd?  Can't a resource be itself?  So that I can set the Datacontext in the XAML instead of code behind?  I've tried to bind to relative source self, but cannot set the property (Event when I attempted to created a dependency property).....  Just wondering how one sets up Datacontext to the same class? 


How can I pass a NULL value as [in,out] argument to a COM method using late binding?


Suppose I have the following method in a COM interface defined in a C++ IDL:

[id(8)] HRESULT MyMethod([in,out,defaultvalue(NULL)] LONG* value, [out, retval] BSTR* returnValue);

Now I want to call this method passing in NULL for the 'value' parameter using late binding in C#. How can this be accomplished?

The following works if I want to pass a non-null argument as value:

         Type type = Type.GetTypeFromCLSID(new Guid("{7DA7BD6A-3E11-4E6B-BDE3-7C968A085F94}"));
         object instance = Activator.CreateInstance(type);

         object[] arguments = new object[] { 101 };

         ParameterModifier modifier = new ParameterModifier(1);

         modifier[0] = true;

         type.InvokeMember("[DispID=8]", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, instance, arguments, new ParameterModifier[] { modifier }, null, null);

         Console.WriteLine("Value after call: {0}", arguments[0]);

But how can I pass NULL? Using 'null' or Type.Missing give me type

VB.Net Late binding operations cannot be converted to an expression tree.


Hi I get this error
"Late binding operations cannot be converted to an expression tree."

At all my x.NAME) lines !?

Im new to this so can anyone say me why i get this error..
Hvorfor gør den det !?


        <div>Navn: <%: Html.EditorFor(Function(x) x.Name)%></div>
        <div>Linje 1: <%: Html.EditorFor(Function(x) x.Line1)%></div>
        <div>Linje 2: <%: Html.EditorFor(Function(x) x.Line2)%></div>
        <div>Linje 3: <%: Html.EditorFor(Function(x) x.Line3)%></div>
        <div>Postnr: <%: Html.EditorFor(Function(x) x.Zip)%></div>
        <div>By: <%: Html.EditorFor(Function(x) x.City)%></div>
        <div>Landsdel: <%: Html.EditorFor(Function(x) x.Country)%></div>
            <%: Html.EditorFor(Function(x) x.GiftWrap)%>
            Disse vare skal i Gaveindpakning.

loading generic types with late binding




  I'm trying to late bind a generic datatype at runtime.  Basically the assembly for this generictype is in a different directory (not a sub directory).  So I can't use private probing.  Its not reliably in the GAC either, so I can't depend on that.  I can load several other types from this assembly but not this generic type.


So in the assembly the datatype is of the form MyGenericDataType

and at runtime I want the type of MyGenericDataType.


Any idea how to do that?  I tried:


Code Block

Assembly MyAssembly = Assembly.LoadFile("Path to assembly DLL");


Type MyType = MyAssembly.GetType("MyGenericDataType<MyRegularDataType>");




MyType always equals null.


Do I need to load MyGenericDataType first and then somehow convert it to MyGenericDataType ?



Change the default size of http binding - question about


I change the http binding buffer size to be maximum possible.


<binding name="LargeData_basicHttpBinding" maxBufferSize="2147483647" 
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> 
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

Binding Nested Listviews in MVC ViewPage


I am a longtime .NET developer but for big applications and services.  This is my first asp.net project and I have chosen MVC.   I have a need for nesting a ListView within a ListView.  In this simple catalog app, I have EF 4 Entities that are Categories, SubCategories, ItemTypes, and Items.

My goal is to display a 5 column layout of SubCategories with their ItemTypes below them in a ViewPage.  I did just fine with it done out in C# as server directives such as:

    var subcats = Model.SubCategory.ToArray();
    var nrSubCats = subcats.Count();
    var rows = (nrSubCats/5) + (((nrSubCats % 5) > 0) ? 1 : 0);
    for (var row = 0; row < rows; row++)
    { %>
        <div style="width: 100%; float: left; clear: right;">
        var start = row * 5;
        for (var i = start; (i < start + 5) && (i < nrSubCats); i++)
        var subcat = subcats[i];
            <div style="float: left; clear: right; width: 20%; margin-left: 5;">
                <h2> <%:subcat.Name%></h2>
                    foreach (var its in subcat.ItemType)

Some basic MVC question

  1. In regular asp net I can run (debug) the application but I can either "view in browser" that gives me the option to view the application and write code on same time.

In MVC I can't find this option.

  1. What is the basic DATA MODEL for working with SQL DB.

I mean with no any framework (entity framework, Sub sonic, Link to SQL etc')

I look for basic application that works with data but with no fw.

  1. What is the popular DB framework that working with data.
  2.  I am looking on  mvc series


C# Soup To Nuts  (the best series ever)


I watch some of the MVC video, seems that the music store is good but I have to wait to the other part.

Does any one know and recommend   a Microsoft MVC tutorial?





Web Site to Web Application Question


I've been building web sites and for my next project I will be creating a web application.  I use a 'BasePage' class in all my projects but, since web applications do not contain the 'App_Code' folder, what is the best place/practice for the 'BasePage' class?



connection string question from a newbie


when publishing  in the webmatrix dialogue it asks for "destination connection string" for my "database.mdf"

I was not sure what it was so I pasted this from my web.config file :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True

it all published ok, but wont run, so I guess it has somthing to do with this connection string or some kind of configuration issue.

My question is this, What should go in the field for "Destination connection string"

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