我从存储过程中绑定了我的gridview
(dgvresult2
)读取数据。当我调试gridview.rows.count
时,虽然我的DataSet
表有5行(ds.Tables[0].Rows.Count
),但它为零。
请帮忙解决这个问题 - 以下是我的代码:
private void ReturnResult ( )
{
try
{
string connetionString = null;
lblcino.Text = "1234";
connetionString = "Data Source= SLB-84NKBT1\\SQLEXPRESS;Initial Catalog=WireLine Tracking Assets; User=admin; pwd=password123";
SqlConnection connection = new SqlConnection(connetionString);
connection.Open();
SqlCommand command = new SqlCommand("GetCIno", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@CustomerInvoiceNo", SqlDbType.NChar).Value = lblcino.Text; //((Label)dgvresult.FooterRow.FindControl("lblcino")).Text;
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(ds);
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
dgvresult2.DataSource = ds;
dgvresult2.DataBind();
dgvresult2.Visible = true;
}
}
else
{
string message = "ds is Empty";
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + message + "');", true);
}
connection.Close();
}
catch (Exception)
{
throw;
}
}