日期:2014-05-18  浏览次数:20611 次

请教一个Repeater控件返回值问题!!!!!!!!!!
我做一个显示新闻内容的页面,怎么点击   HyperLinkColumn
( <asp:HyperLinkColumn
HeaderText= "文章标题 "
DataTextField= "topic "
DataNavigateUrlField= "ID "
DataNavigateUrlFormatString= "show.aspx?ID={0} "
  > )
连接TOPIC,没有数据显示?

protected   void   Repeater1_ItemCommand(object   source,   RepeaterCommandEventArgs   e)
        {

                SqlConnection   conn1   =   new   SqlConnection();
                SqlDataAdapter   adpt   =   new   SqlDataAdapter();


                conn1.ConnectionString   =   "Data   Source=DIMETA;Initial   Catalog=dimet;User   ID=sa;Password= ";
                conn1.Open();
                string   ID   =   Request.QueryString[ "ID "];
                string   sql   =   "Select   author,topic,content,fb_date   from   test   where   ([ID]=@ID) ";

                adpt   =   new   SqlDataAdapter(sql,   conn1);
                DataSet   ds   =   new   DataSet();
                adpt.Fill(ds,   "test ");
                Repeater1.DataSource   =   ds.Tables[ "test "].DefaultView;
                Repeater1.DataBind();
                conn1.Close();
        }
调试时,地址栏ID也能取出怎么就是没有显示,也没有报错,真是怪了
请高手帮我指点一下,我用的是DotNET2.0

------解决方案--------------------
string sql = "Select author,topic,content,fb_date from test where ([ID]=@ID) ";

你这个是带参数的SQl语句...要传参数进去的要不就改成

string sql = "Select author,topic,content,fb_date from test where ID= " + ID;