求助错误处理
错误 1 “System.Web.UI.WebControls.GridView”并不包含“Items”的定义 D:\MyCommerceSite\JokePoint\AdminUserControls\ProductsAdmin.ascx.cs 141错误代码:
protected void productsGrid_SelectedIndexChanged(object sender, System.EventArgs e)
{
string departmentId = Request.QueryString["DepartmentID"];
string categoryId = Request.QueryString["CategoryID"];
string productName = productsGrid.Items(productsGrid.SelectedIndex).Cells[1].Text;
string productId = productsGrid.DataKeys[productsGrid.SelectedIndex].ToString();
string imagePath = productsGrid.Items(productsGrid.SelectedIndex).Cells(4).Text;
Response.Redirect("admin.aspx?DepartmentID=" + departmentId + "&CategoryID=" + categoryId + "&ProductID=" + productId + "&ProductName=" + productName + "&ImagePath=" + imagePath);
}
错误 3 无法将方法组“Read”转换为非委托类型“bool”。您是要调用方法吗? D:\MyCommerceSite\JokePoint\AdminUserControls\ProductDetailsAdmin.ascx.cs 48
错误代码:
protected void FillControls()
{
// Set the product name
productNameLink.Text = Request.QueryString["ProductName"];
// Display the product's image.
productImage.ImageUrl = "../ProductImages/" + Request.QueryString["ImagePath"];
// Get the ProductID from the query string
string productId = Request.QueryString["ProductID"];
// Get the list of categories into a SqlDataReader object
SqlDataReader reader;
reader = CatalogAdmin.GetCategoriesForProduct(productId);
// Temporary variables we'll use in this method
string categoryName;
string categoryId;
int categoriesCount=0;
// Read each category and add its name to the label
categoriesListLabel.Text = "";
while ((reader.Read))
{
// extract the category ID from the SqlDataReader
categoryId = reader.GetValue(0).ToString();
// extract the category name from the SqlDataReader
categoryName = reader.GetValue(1).ToString();
// append category links to the Label
categoriesListLabel.Text += "<a href=\"" + Request.Url.AbsolutePath + "?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + categoryId + "\">" + categoryName + "</a>" + "; ";
// increase the number of categories the selected product belongs to
categoriesCount = categoriesCount + 1;
}
// Set the text of the Delete button depending on
// the number of categories
if (categoriesCount == 1)
{
// Set the text on the Remove button
removeButton.Text = "Remove product from catalog";
}
else
{
// Obtain the Category ID from the query string
categoryId = Request.QueryString["CategoryID"];
// Get the name of the current category from the database
categoryName = Catalog.GetCategoryDetails(categoryId).Name;
// Set the text on the Remove button
removeButton.Text = "Remove product from category: " + categoryName;
}
// Close the SqlDataReader. This will also close the data connection
reader.Close();
// Get all the categories, to populate the DropDownList with them
reader = CatalogAdmin.GetCategoriesForNotProduct(productId);
// Add the list of categories to the DropDownList objects
categoriesList.Items.Clear();
categoriesList2.Items.Clear();
while ((reader.Read))
{
// extract the category ID from the SqlDataReader
categoryId = reader.GetValue(0).ToString();
// extract the category name from the SqlDataReader
categoryName = reader.GetValue(1).ToString();
// add the category to the CategoriesList dropdown
categoriesList.Items.Add(new ListItem(categoryName, categoryId));
// add the category to the CategoriesList2 dropdown
categoriesList2.Items.Add(new ListItem(categoryName, categoryId));
}
// Close the SqlDataReader. This will also close the data connection
reader.Close();
} --------------------编程问答-------------------- 怎么没人回答啊!!!! --------------------编程问答-------------------- 我是新手, 我也出现类似的问题:
代码如下: string CompID = "";
string sqlStatementStr = "select CC.CompID 公司编号,CC.CID 联络编码,CC.客服专员,CC.联系日 期,CC.联系记录,CC.CreateBy 创建人, " +
"CC.CreateDate 创建时间,CC.语音记录,CC.相关文档,CC.客户评级,CC.后续服务 from CustomerCon CC,Company C " +
"where CC.CompID like " + Convert.ToString(GridViewComp.SelectedValue) + " and C.UserID like '" + UserName + "'";
SqlCommand myCommand = new SqlCommand(sqlStatementStr, myConnection);
SqlDataReader reader = myCommand.ExecuteReader();
if (reader.Read())
{
CompID = reader["CompID"].ToString;
}
编绎时报错:错误 5 无法将方法组“ToString”转换为非委托类型“string”。您是要调用方法吗? D:\My Documents\Visual Studio 2005\WebSites\PurshMis2\PurshMis\FirstPage.aspx.cs 82 38 D:\...\PurshMis2\
请大侠指教啊. 急!!!!! --------------------编程问答-------------------- 太有才了 --------------------编程问答--------------------
toString改为toString()试试。
补充:.NET技术 , ASP.NET