I'm making a website inside the Visual Studio using asp.net. My website is connected to Web Serbice Server which is connected to SQL database.
On my mainpage.aspx, at the top of the file, I have the first following line:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mainpage.aspx.cs"
Inherits=WebApplication.mainpage" %>
Later in the same mainpage.aspx file I have a dropdown list:
<asp:DropDownList ID="DropDownList1" runat="server" width="140px"></asp:DropDownList>
In my mainpage.aspx.cs file I'm writing the following code inside the 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 DataBase Table:
ID_Comp | int | (Primary Key)
----------------------------
Comp_Name | nvarchar(50) |
What am I doing wrong? I've followed the instructions of multiple tutorials but nothing so far has worked. Is there something fundamental I'm missing?
