凯在这里,我有这个代码保持生成此错误“抛出新的Notimplementedexception();” ...请帮忙 [英] Kay Here, I Have This Code That Keeps Generation This Error "Throw New Notimplementedexception();" ...Please Help
问题描述
这是我的代码,当我在浏览器上查看时,返回页面空白回来
this is my code, and when I view it on my browser the return page comes back blank
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
public string strconnString { get; set; }private string strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataBind();
string strQuery = "select Reader_name, book_name,book_author,borrow_date,expected return_date" + "from readers Query";
SqlCommand cmd = new SqlCommand(strQuery);
GridView1.DataSource = GetData(cmd);
GridView1.DataBind();
}
}
protected void EditReader(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
DataBind();
}
protected void CancelEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
DataBind();
}
protected void UpdateReader(object sender, GridViewUpdateReaderEventArgs e)
{
string Readername = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtReadername")).Text;
string Bookname = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtbookname")).Text;
string Bookauthor = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBokkauthor")).Text;
string BorrowDate = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBorrowdate")).Text;
string ExpectedreturnDate = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtexpectedreturndate")).Text;
SqlConnection con = new SqlConnection(strconnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update Reader name=@Reader name," + "Book name=@Book name," + "Book author=@Book author, " + " Borrow date=@Borrow date ," + " expected return date=@expected return date where Reader name=@reader name;" +
"select Reader name,Book name,Book author,Borrow date,expected return date from Query table";
cmd.Parameters.Add("@Readername", SqlDbType.VarChar).Value = Readername;
cmd.Parameters.Add("@Bookname", SqlDbType.VarChar).Value = Bookname;
cmd.Parameters.Add("@Bookauthor", SqlDbType.VarChar).Value = Bookauthor;
cmd.Parameters.Add("@BorrowDate", SqlDbType.VarChar).Value = BorrowDate;
cmd.Parameters.Add("@ExpectedreturnDate", SqlDbType.VarChar).Value = ExpectedreturnDate;
GridView1.EditIndex = -1;
GridView1.DataSource = GetData(cmd);
GridView1.DataBind();
protected void DeleteReader(object sender, EventArgs e)
{
LinkButton lnkRemove = (LinkButton)sender;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "delete from readers Query where " + "Readerame=@Readername;" + "select Reader name,Book name,Book author,Borrow date,expected return date from reader Query";
cmd.Parameters.Add("@Readername", SqlDbType.VarChar).Value = lnkRemove.CommandArgument;
GridView1.DataSource = GetData(cmd);
GridView1.DataBind();
}
}
推荐答案
throw new NotImplementedException;
不是错误:它是teh系统告诉你,你忘了添加代码来实际让方法做你想做的事!
使用Visual Studio填空并为您创建一个方法,它创建的模板只包含那一行 - 这样当您在开发中运行代码时,强行提醒您,您的代码将无法正常工作,因为您尚未编写它! :笑:
所以看看你的代码,找到你还没写的方法 - 并写下来......
Is not an error: it's teh system telling you that you forgot to add code to actually make a method do what you wanted it to do!
When you use Visual Studio to "fill in the blanks" and create a method for you, the template it creates contains only that one line - so that when you run your code in development you are forcibly reminded that your code will not work correctly because you haven't written it yet! :laugh:
So look in your code, find the method(s) that you haven't written yet - and write them...
这篇关于凯在这里,我有这个代码保持生成此错误“抛出新的Notimplementedexception();” ...请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!