dub_beat

Hi,

Just a quick question. Can you use the sql data source with a mobile web form.

This code does not give me any errors but nothing gets displayed

*************************

<mobile:Form id="Form1" runat="server">
<mobile:List ID="lst" runat="server" DataSource="<%# SqlDataSource1 %>" >

</mobile:List>

</mobile:Form>
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:mobile_projectConnectionString5 %>"
selectcommand="SELECT [username], [password] FROM [members]"></asp:sqldatasource>

*************************


Re: Smart Devices General mobile web form & sql data source

Zero Dai - MSFT

Dear dub_beat,

Yes, we can use SqlDataSource, but we cannot use it if we drag it onto a web form directly, since SqlDataSource control from tool box is a non-mobile control, which is permitted only inside templates. So, you need to add a device filter for your mobile control and edit its template, then you can drag non-mobile onto this template.

The root cause of your problem is that your mobile control list cannot access sqldatasource.

When you take a look into html of a web form, all the prefix of controls has been set to "mobile", so control with prefix "asp:" cannot be recognized.

Also, we still can use it with writing our code in back codefile. You can use sqldatasource as following:

------------------------------------------------------------------------------------

SqlDataSource datasource = new SqlDataSource();
datasource.ConnectionString
= ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ToString();
datasource.SelectCommand = "select UserName from UserInfo";
datasource.SelectCommandType = SqlDataSourceCommandType.Text;
datasource.Select(new DataSourceSelectArguments());

this.ObjectList1.AutoGenerateFields = true;
this.ObjectList1.DataSource = datasource;
this.ObjectList1.DataBind();

------------------------------------------------------------------------------------

Regards,

Zero Dai - MSFT