在更新新闻中,用DropDownList获取数据库NewsKind字段的值 ASP.NET 2.0 C#
在更新新闻中,用DropDownList获取数据库NewsKind字段的值,获得的值不正确,出现错位。在数据库中是国内新闻,而获取后显示为国外新闻。
UpdateNews.aspx.cs的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindData();
}
}
public void BindNewsKind()
{
this.DropNewsKinds.DataSource = NewsKinds.GetAllNewsKinds();
this.DropNewsKinds.DataTextField = "KindName";
this.DropNewsKinds.DataValueField = "KindId";
this.DropNewsKinds.DataBind();
}
public void BindData()
{
if (Request.QueryString["id"] != null)
{
BindNewsKind();
int NewsId = Convert.ToInt32(Request.QueryString["id"]);
News SingleNews = new News();
SingleNews = News.GetNewsByNewsId(NewsId);
this.TxtNewsTitle.Text = SingleNews.NewsTitle;
this.DropNewsKinds.SelectedIndex = SingleNews.NewsKindId;
this.WebNewsBody.Text = SingleNews.NewsBody;
}
}
请高手指教! --------------------编程问答-------------------- 调试一下你的程序,应该是传值有问题 --------------------编程问答-------------------- 参考:
http://blog.csdn.net/insus/archive/2008/03/26/2221260.aspx --------------------编程问答-------------------- 这个问题是在浪曦--新闻发布系统里发现的,有没有调试过的,请指教. --------------------编程问答-------------------- 应该是参数传值出现的异常吧,LZ调试先...
补充:.NET技术 , ASP.NET