我正在使用asp.net在Visual Studio中创建一个网站。 我的网站已连接到连接到SQL数据库的Web Serbice Server。将数据绑定到ASP.NET中的DropDownList
在我mainpage.aspx,在文件的顶部,我有第一以下行:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mainpage.aspx.cs"
Inherits=WebApplication.mainpage" %>
在同一mainpage.aspx文件我有一个下拉列表稍后:
<asp:DropDownList ID="DropDownList1" runat="server" width="140px"></asp:DropDownList>
在我mainpage.aspx.cs文件我写的Pade_Load()内以下代码:
DataSet Company = WebSerivce.Company(IP, DataBaseName, UserName, Password);
DataTable cTable = Company.Table[0];
if(!Page.IsPostBack)
{
DropDownList1.DataSource = cTable;
DropDownList1.DataValueField = "ID_Comp";
DropDownList1.DataTextField = "Comp_Name";
DropDownList1.DataBind();
}
SQL数据基表:
ID_Comp | int | (Primary Key)
----------------------------
Comp_Name | nvarchar(50) |
我在做什么错?我遵循多个教程的说明,但目前为止没有任何工作。有什么基本的我失踪了?
您是否在cTable中获得了价值? –
如何检查? – OverflowStack
“使用调试”。 .1。在“数据集公司”保留一个调试点2.运行应用程序..执行将在该点进行,您可以在c表中看到该值表 – Webruster