locked
Databinding control properties. RRS feed

  • Question

  • User1214340414 posted

    I have database of restaurant addresses that I would like to be able to access using the browser on my cell phone. I have set up a form with the controls that I would like on it and I set the properties for the controls manually to test it and I looks fine.  Now I would like to remove the manually set property values and be able to set the properties dynamically from data in dataset named Addresses. 

     

    I believe I would start with:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not IsPostBack Then

    Dim ta As New AddressesTableAdapters.AddressesTableAdapter

    Dim dt As New Addresses.AddressesDataTable

    ta.Fill(dt)

    ......................................................................................................................................................................................................

    From here on I'm not sure how to write the database values into the text properties of the following form controls.

    <mobile:Form ID="China" Runat="server">

    <mobile:Link ID="Link14" Runat="server" Alignment="Center" NavigateUrl="#Home" SoftkeyLabel="Home"

    StyleReference="title">phonetag.info</mobile:Link>

    <mobile:Label ID="Label11" Runat="server" Alignment="Center" StyleReference="title">China</mobile:Label>

    <mobile:TextView ID="TextView1" Runat="server" Alignment="Center" Font-Size="Small">2816 Washington Road</mobile:TextView>

    <mobile:TextView ID="TextView2" Runat="server" Alignment="Center" Font-Size="Small">Augusta, GA 30909</mobile:TextView>

    <mobile:TextView ID="TextView3" Runat="server" Alignment="Center">

    <a href="wtai://wp/mc;7067388998">706-738-8998</a>

    </mobile:TextView>

    <mobile:TextView ID="TextView4" Runat="server" Alignment="Center" Font-Size="Small">

    <a href="wtai://wp/ap;7067388998;China">Add to Your Contacts</a>

    </mobile:TextView><mobile:TextView ID="TextView6" Runat="server" Alignment="Center" Font-Size="Small">

    Description

    </mobile:TextView>

    </mobile:Form>

    Sunday, July 30, 2006 11:06 PM

All replies

  • User-368580566 posted

    One way to do it is to create a panel on your page. Then in the code loop through the datatable creating and filling the controls and adding them to the panel.

    Something like this:

    Dim body_txt As MobileControls.TextView

    For Each row As DataRow In dt.Rows

    body_txt = New MobileControls.TextView

    body_txt.Text = row("ColumnName").ToString

    body_Panel.Controls.Add(body_txt)

    Next

    Thursday, August 3, 2006 8:52 AM