REF: Simple Binding Problem - Help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: REF: Simple Binding Problem - Help

  1. #1
    Join Date
    Jun 2009

    REF: Simple Binding Problem - Help

    I have code which binds to XAML but its not working, do i need to specifically specify the data source in my XAML I am stuck here is my code:

    Code Behind:

    MySqlConnection connection;
    DataSet ds;
    MySqlDataAdapter da;

    public Window1()

    connection = new MySqlConnection("server=localhost;Database=testdatabase;Port=3306;uid=root;pwd=password");

    ds = new DataSet();
    da = new MySqlDataAdapter("select FirstName, LastName from personalDetails", connection);
    da.Fill(ds, "personalDetails");
    grdRoot.DataContext = ds;
    catch (Exception ex)


    XAML Code:

    <Window x:Class="TestApplication.Window1"
    Title="Window1" Height="300" Width="300">
    <Grid x:Name="grdRoot">
    <Label Height="28" Margin="12,71,0,0" Name="lblFirstName" VerticalAlignment="Top" HorizontalAlignment="Left" Width="62">Fisrt Name</Label>
    <TextBox Height="23" Margin="80,73,78,0" Name="txtFirstName" VerticalAlignment="Top" Text="{Binding Path=FirstName}" />
    <Label Margin="12,105,0,129" Name="lblLastName" HorizontalAlignment="Left" Width="67">Last Name</Label>
    <TextBox Margin="80,105,78,0" Name="txtLastName" Height="23" VerticalAlignment="Top" Text="{Binding Path=LastName}"/>

    What am i missing out here, the code is not giving errors its just not displying the data:

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    Re: REF: Simple Binding Problem - Help

    Is MySqlDataAdapter derived from ObservableCollection?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)