当前位置:编程学习 > C#/ASP.NET >>

detailsview的问题


为啥我这行代码,在detailsview中无法显示数据??
   
     if (!this.IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                string id = Request.QueryString["id"].ToString();
                String strConnection = ConfigurationSettings.AppSettings["ConnectionString"];
                SqlConnection myConnection = new SqlConnection(strConnection);
                myConnection.Open();
                SqlCommand cmd = new SqlCommand("select wenti from classdata11 where id=+'" + id + "'", myConnection);
                this.Label1.Text = Convert.ToString(cmd.ExecuteScalar());
                cmd.CommandText = "select * from classdata11 where id='" + id + "'";
                SqlDataReader sdr = cmd.ExecuteReader();
                this.DetailsView1.DataSource = sdr;
                this.DetailsView1.DataBind();
            } --------------------编程问答-------------------- 贴html~ --------------------编程问答-------------------- 哈哈自己解决,和datalist的是一样 --------------------编程问答-------------------- <asp:DetailsView ID="DetailsView1" DataKeyNames="id" runat="server" Height="148px" Width="381px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="1" CellSpacing="1" OnPageIndexChanging="DetailsView1_PageIndexChanging">
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
        </asp:DetailsView>
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,