.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

Error Binding Data

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net

I am receiving an error when trying to bind data.  I went to sql server and wrote the query first to make sure that it works properly, and the data was returned successfully.  I'm not sure what I am doing wrong.  Here is my code:

protected void Page_Load(object sender, EventArgs e)
        //Declare connection object
        SqlConnection Conn = new SqlConnection();

        Conn.ConnectionString = ConfigurationManager.ConnectionStrings["5284"].ConnectionString;

            lblMessage.Text = "Connection to Server Failed";

        //Define query
        string sql = "SELECT dboProduct.ProductID, dbo.Product.ProductName, dbo.Product.ProductNumber, dbo.Vendor.VendorName, dbo.lu_Category.Description, dbo.Product.QtyOnHand FROM dbo.Product INNER JOIN dbo.Vendor ON dbo.Product.VendorID = dbo.Vendor.VendorID INNER JOIN dbo.lu_Category ON dbo.Product.CategoryID = dbo.lu_Category.CategoryID";
        //Declare a SQL adapter
        SqlDataAdapter da = new SqlDataAdapter(sql, Conn);

        //Declare a DataTable
        DataTable dt = new DataTable();

        //Populate the DataTable

        //Bind to listview
        lv.DataSource = dt;

View Complete Post

More Related Resource Links

Data binding - strange error message

Hi, I am getting an inexplicable error message on attempting to run a simple WPF data binding application based on an example with video downloaded from MSDN. VB / VS 2008 Pro / .NET 3.5 SP1 / XP SP3 The error (ex.Message) is "The specified registry key does not exist" in response to an attempt to define the data context to populate a listbox, but no explicit registry operation is involved at all. The code is: Private taTable1 As New D1DataSetTableAdapters.Table1TableAdapter Private D1Data As New D1DataSet . . . Try     Me.taTable1.Fill(Me.D1Data.Table1)     Me.DataContext = Me.D1Data.Table1        ' this statement generates the exception Catch ex As Exception The error message is giving no obvious clue.  What is going on? P.S. The MSDN sample application uses the following code to sort the listbox items: Me.DataContext = From p In Me.dsProduct.Product Order By p.Name This construct does not work when I try to use it - VS 2008 reports that "'Name' is not a member of 'System.Data.DataRow'".  How may this error be avoided? JPL

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 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.

datarow data insertion error


this is the code which i am using and what i want means when i==0 first record should bind to datatable and when i==1 2nd record should bind to datatable. that means when i==1 1st and 2nd record should be present in datatable  Please see the code below


when i am binding 2nd record to datatable 1st record is getting deleted and recently inserted value is getting inserted please tell me how to resolvie this


datatable dt11=new datatable();
DataRow row11=null;

if (i == 0)
row11 = dt11.NewRow();

row11["qid"] = qnumber;

row11["question"] = question;
row11["useranswer"] = correctans;
row11["flag"] = answerstatus;


if (i == 1)

qnumber =ds5.Tables[0].Rows[i][0].ToString();
question =ds5.Tables[0].Rows[i][1].ToString();

row11 = dt11.NewRow();

Error while adding pollingduplex binding


I am making samle of polling duplex in .net 4.0

when ever i put binding this tag in web.config it shows error.


Warning    1    The element 'bindings' has invalid child element 'pollingDuplexHttpBinding'. List of possible elements expected: 'basicHttpBinding, customBinding, msmqIntegrationBinding, netPeerTcpBinding, netMsmqBinding, netNamedPipeBinding, netTcpBinding, wsFederationHttpBinding, ws2007FederationHttpBinding, wsHttpBinding, ws2007HttpBinding, wsDualHttpBinding, netTcpContextBinding, wsHttpContextBinding, basicHttpContextBinding, mexHttpBinding, mexHttpsBinding, mexNamedPipeBinding, mexTcpBinding, webHttpBinding'.    D:\DuplexTest\TestPollingDuplexWcf\TestPollingDuplexWcf\TestPollingDuplexWcf\Web.config    9    8    TestPollingDuplexWcf

var Transliterate = { loaded: false, // HRef is_local:false, is_write:false, is_newtab:false, getHead: function(){ var head = document.getElementsByTagName('head')[0]; if (!head) { return document.body; } return head; }, addGlobalStyle: function(css) { var head = Transliterate.getHead(); var style = document.createElement('style'); style.type =

Cutting Edge: Live Data Binding in ASP.NET AJAX 4.0


Dino Esposito discusses various forms of client-side data binding as they are coming out in ASP.NET AJAX 4.0, focusing on some advanced features of data binding and observable objects.

Dino Esposito

MSDN Magazine December 2009

Cutting Edge: Data Binding in ASP.NET AJAX 4.0


In this article, Dino reviews the pillars of real-world AJAX development as supported in ASP.NET AJAX 4.0. In doing so, he mostly focuses on client-side templates and data-binding but doesn't ignore other goodies, such as ADO.NET Data Services proxy classes and programming facilities.

Dino Esposito

MSDN Magazine October 2009

Dynamic WPF: Create Flexible UIs With Flow Documents And Data Binding


Flow documents offer enormous flexibility in arranging text layout and pagination, but they don't support data binding, so you can't dynamically change content. Here we build a component to solve that problem.

Vincent Van Den Berghe

MSDN Magazine April 2009

Data and WPF: Customize Data Display with Data Binding and WPF


Here we present techniques for programmatic and declarative data binding and display with Windows Presentation Foundation.

Josh Smith

MSDN Magazine July 2008

Extreme ASP.NET: The Only Data-binding Control You'll Ever Need


Fritz Onion demonstrates how the ListView control in ASP.NET 3.5 makes data-binding tasks easier with support for styling with CSS, flexible pagination, and a full complement of sorting, inserting, deleting, and updating features.

Fritz Onion

MSDN Magazine March 2008

Data Points: Data Binding in WPF


WPF is one of the most important new technologies in the .NET Framework 3.0. This month John Papa introduces its data binding capabilities.

John Papa

MSDN Magazine December 2007

Extend ASP.NET: Simplify Data Binding In ASP.NET 2.0 With Our Custom Control


The wwDataBinder control addresses simple control data binding--binding simple form controls like textboxes, checkboxes, and the selected values of list controls to individual data or object values.

Rick Strahl

MSDN Magazine December 2006

Office Unbound: Bring Your Documents To Life With Data Binding In Visual Studio Tools For Office


Thanks to Visual Studio 2005 Tools for the Microsoft Office System, Windows Forms controls can be bound to databases, Web services, or objects and added to a workbook or document. Find out how.

Eric Carter and Eric Lippert

MSDN Magazine March 2006

Data Binding: Give Your Everyday Custom Collections a Design-Time Makeover


In this article, Paul Ballard shows how you can provide data binding support for your custom collections to enable sorting, searching, and editing in as simple a manner as possible. In addition, he shows how to make all of these features available in the Windows and Web Forms Designers, just like an ADO.NET DataSet.

Paul Ballard

MSDN Magazine August 2005

Cutting Edge: Collections and Data Binding


When it's time to design the Data Access Layer (DAL) of your distributed Microsoft® . NET Framework-based app, one of the key decisions you'll make is how you'll pass data to and from methods of DAL classes.

Dino Esposito

MSDN Magazine May 2005

Advanced Basics: Data Binding in Visual Basic .NET


Ken Spencer introduces data binding in Visual Basic .NET.

Ken Spencer

MSDN Magazine August 2003

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