能给我解释一下吗

zjzhz 2003-03-05 11:21:55
我将一个update.cs文件编译成update.dll,提示“namespacewww.update.DataBind()将隐藏继承的成员System.Web.UI.Control.DataBind(),若要使当前成员重写该实现,请添加关键字override,否则添加关键字new。System.Web.dll(与前一个警告相关的符号位置”。请问以上提示什么意思,如何解决。
...全文
65 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-03-06
  • 打赏
  • 举报
回复
try to change

void DataBind()
{
//....
==>
public override void DataBind()
{
// base.OnDataBinding(EventArgs.Empty);//you might need this
//.....
zjzhz 2003-03-05
  • 打赏
  • 举报
回复
update.cs代码如下:

using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


namespace www
{
public class updateMyCodeBehind : Page
{
public DataGrid MyList;
public DropDownList DropDownList1;
public DropDownList DropDownList2;
public TextBox TextBox1;
public LinkButton btnFirst;
public LinkButton btnPrev;
public LinkButton btnNext;
public LinkButton btnLast;
public Label lblCurrentPage;
public Label lblPageCount;
public Label lblRecordCount;
public TextBox txtIndex;

public int PageCount,RecordCount;


private void Page_Load(Object sender, EventArgs e)
{

if(!IsPostBack)
{
SqlConnection MyConnection =new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter myCommand=new SqlDataAdapter("SELECT id,typename FROM bb ",MyConnection);
DataSet ds= new DataSet();
myCommand.Fill(ds,"bb");
DropDownList2.DataSource = ds.Tables["bb"].DefaultView;
DropDownList2.DataTextField = "typename";
DropDownList2.DataValueField = "id";
DropDownList2.DataBind();
DataBind();
}
DataBind();
}


DataView CreateDataSource()
{
SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter myCommand = new SqlDataAdapter("select * from aa WHERE typeid="+ DropDownList2.SelectedItem.Value+" order by shijian desc", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "aa");
return ds.Tables["aa"].DefaultView;
}

void DataBind()
{
DataView source=CreateDataSource();
if(!IsPostBack)
{

RecordCount=source.Count;
PageCount=RecordCount/MyList.PageSize;
if((RecordCount%MyList.PageSize)!=0) PageCount++;
lblRecordCount.Text=RecordCount.ToString();
lblPageCount.Text=PageCount.ToString();
lblCurrentPage.Text="1";
}
MyList.DataSource = source;
MyList.DataBind();
}

public void MyList_Page(Object sender, DataGridPageChangedEventArgs e)
{
//由内置页导航使用。CurrentPageIndex 已设置
MyList.CurrentPageIndex = e.NewPageIndex;
DataBind();
}

public void txtIndex_Changed(Object sender, EventArgs e)
{

btnFirst.Enabled=true;
btnPrev.Enabled=true;
btnNext.Enabled=true;
btnLast.Enabled=true;

int index=Int32.Parse(txtIndex.Text.ToString());
PageCount=Int32.Parse(lblPageCount.Text.ToString());
if(index>=1&&index<=PageCount)
{
MyList.CurrentPageIndex=index-1;
DataBind();
lblCurrentPage.Text=index.ToString();

if(index==1)
{
btnFirst.Enabled=false;
btnPrev.Enabled=false;
}
else if(index==PageCount)
{
btnLast.Enabled=false;
btnNext.Enabled=false;
}


else

{ txtIndex.Text=""; }
DataBind();
}
}

public void PagerButtonClick(Object sender, CommandEventArgs e)
{
btnFirst.Enabled=true;
btnPrev.Enabled=true;
btnNext.Enabled=true;
btnLast.Enabled=true;

//由外部分页 UI 使用
String arg = e.CommandArgument.ToString();

PageCount=Int32.Parse(lblPageCount.Text.ToString());
int pageindex=Int32.Parse(lblCurrentPage.Text.ToString())-1;

switch(arg)
{
case "Next":
if (pageindex < (PageCount - 1))
pageindex ++;
break;
case "Prev":
if (pageindex > 0)
pageindex --;
break;
case "Last":
pageindex = (PageCount - 1);
break;
case "First":
pageindex=0;
break;
}
if(pageindex==0)
{
btnFirst.Enabled=false;
btnPrev.Enabled=false;
}
else if(pageindex==PageCount-1)
{
btnLast.Enabled=false;
btnNext.Enabled=false;
}
MyList.CurrentPageIndex=pageindex;
DataBind();
lblCurrentPage.Text=(MyList.CurrentPageIndex+1).ToString();

}

public void SubmitBtn_Click(Object sender, EventArgs e)
{

{

SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter myCommand = new SqlDataAdapter("select * from aa where " + DropDownList1.SelectedItem.Value + " like '%" + TextBox1.Text.ToString() + "%'", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "tt");

MyList.DataSource = ds.Tables["tt"].DefaultView;
MyList.DataBind();
}
}


public void MyDataGrid_Delete(Object sender, DataGridCommandEventArgs e)
{
SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
String deleteCmd = "DELETE from aa where id = @Id";
SqlCommand myCommand = new SqlCommand(deleteCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@Id", SqlDbType.Char, 11));
myCommand.Parameters["@Id"].Value = MyList.DataKeys[(int)e.Item.ItemIndex];

myCommand.Connection.Open();

try
{
myCommand.ExecuteNonQuery();

}
catch (SqlException)
{

}

myCommand.Connection.Close();

DataBind();
}

protected string FormatString(string str)
{
str=str.Replace(" ","  ");
str=str.Replace("<","<");
str=str.Replace(">",">");
str=str.Replace('\n'.ToString(),"<br>");
return str;
}


}
}
念.夕夏 2003-03-05
  • 打赏
  • 举报
回复
就是说你写的类的没添加关键字override,也有可能是你没有引入必要的命名空间,最好把代码贴出来,我们也好帮你解决。
saucer 2003-03-05
  • 打赏
  • 举报
回复
show your code

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧