문제

I am new to ASP.NET and C#. I am trying to display some basic information about a "supplier" which is retrieved from a database with a simple query. I started off using a GridView, and it worked perfectly fine, but I like the look of FormView more. The problem is nothing is displaying in the FormView... it is invisible.

Here is the C# code:

connection = new SqlConnection(connectionInfo);
connection.Open();

SqlCommand cmd = new SqlCommand("select... from... where...");
SqlDataReader supplierReader = cmd.ExecuteReader();

supplierForm.DataSource = supplierReader;
supplierForm.DataBind();

supplierReader.Close();
connection.Close();

And here is the ASP code:

<asp:FormView ID="supplierForm" runat="server">
    </asp:FormView>

This is for a class project, so I am not asking you to solve the problem for me. If somebody could just point me in the right direction, that would be great :)

도움이 되었습니까?

해결책

your binding seems correct.

Nevertheless you are missing the binding/markup to display the data in your page - how to do that You might wanna check out these links: MSDN Tutorial for Formview and FormView Control: Step by Step .

Greetz

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top