代码在vs。net里调试没有错误,也可以浏览但是写这样就显示不了界面???
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Drawing" %>
<html>
<head>
<title>商品目录查询</tiele>
</head>
<script language="C#" runat="server">
OleDbConnection myConnection;
protected void Page_Load(Object Src, EventArgs E)
{
myConnection = new OleDbConnection("Location=\"192.168.0.131\";Provider=\"IBMDADB2.1\";Mode=ReadWrite;User ID=db2admin;Data Source=aisnb;Password=db2admin");
if (!IsPostBack)
{
OleDbDataAdapter myCommand = new OleDbDataAdapter("select distinct catalog from commodityinfo", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "catalog");
MySelect.DataSource= ds.Tables["catalog"].DefaultView;
MySelect.DataTextField = ds.Tables["catalog"].Columns[0].ToString();
MySelect.DataValueField =ds.Tables["catalog"].Columns[0].ToString();
MySelect.DataBind();
}
}
protected void MyDataGrid_Sort(Object sender, DataGridSortCommandEventArgs e)
{
BindGrid(e.SortExpression);
}
public void Button_Click(Object sender, EventArgs E)
{
String wherestr = MySelect.SelectedValue.ToString();
String selectCmd = "select * from commodityinfo where catalog = " + "\'" + wherestr + "\'";
OleDbDataAdapter myCommand = new OleDbDataAdapter(selectCmd, myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "commodityinfo");
MyDataGrid.DataSource= ds.Tables["commodityinfo"].DefaultView;
MyDataGrid.DataBind();
}
public void BindGrid(String sortfield)
{
String wherestr = MySelect.SelectedValue.ToString();
String selectCmd = "select * from commodityinfo where catalog = " + "\'" + wherestr + "\'";
OleDbDataAdapter myCommand = new OleDbDataAdapter(selectCmd, myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "commodityinfo");
DataView Source = ds.Tables["commodityinfo"].DefaultView;
Source.Sort = sortfield;
MyDataGrid.DataSource=Source;
MyDataGrid.DataBind();
}
</script>
<body style="font: 10.5pt 宋体">
<form id ="dd" runat="server">
<h3><font face="宋体"><center>商品管理:商品目录查询</center></font></h3>
选择查询条件:
<asp:DropDownList id="MySelect" runat="server" ></asp:DropDownList>
<input type="submit" OnServerClick="Button_Click" Value="查询" runat="server"/><p>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="800"
BackColor="white"
BorderColor="#E7E7FF"
ShowFooter="false"
HorizontalAlign="Center"
CellPadding=3
CellSpacing="0"
Font-Name="Courier New"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
HeaderStyle-HorizontalAlign="Center"
EnableViewState="true"
OnSortCommand="MyDataGrid_Sort"
AllowSorting="true"
/>
</form>
</body>
</html>
在vs。net里web和*.cs文件分开,就没有事,现在合并成一个文件就显示不了
为什么呢?