日期:2014-05-17 浏览次数:20555 次
if (!IsPostBack) { SqlDataReader dr = this.Executeprocedure1("SelectZhuceCompanyType"); if (dr.Read()) { Fanwei.Items.Add(new ListItem(dr["ProductCatalogName_nvarchar"].ToString(), dr["ProductCatalogId_nvarchar"].ToString())); } DataSet ss = new DataSet(); this.Executeprocedure("SelectZhuceCompanyType", ref ss); Fanwei.DataSource = ss.Tables[0].DefaultView; Fanwei.DataTextField = "ProductCatalogName_nvarchar"; Fanwei.DataValueField = "ProductCatalogId_nvarchar"; Fanwei.Items.Clear(); Fanwei.DataBind(); ss.Clear(); ss.Dispose(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bindxx(); } } public void bindxx() { DataSet ds = gc.select_gyss(selecttype); GridView1.DataSource = ds; GridView1.DataBind(); ds.Clear(); ds.Dispose(); }
------解决方案--------------------
DataSet ss = new DataSet();
this.Executeprocedure("SelectZhuceCompanyType", ref ss);
Fanwei.DataSource = ss.Tables[0].DefaultView;
Fanwei.DataTextField = "ProductCatalogName_nvarchar";
Fanwei.DataValueField = "ProductCatalogId_nvarchar";
Fanwei.DataBind();
SqlDataReader dr = this.Executeprocedure1("SelectZhuceCompanyType");
if (dr.Read())
{
Fanwei.Items.Insert(0,new ListItem(dr["ProductCatalogName_nvarchar"].ToString(), dr["ProductCatalogId_nvarchar"].ToString()));
}
单步跟踪看看Fanwei.SelectedValue是否有值
------解决方案--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Table.aspx.cs" Inherits="Table" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> </h