能不能帮我编写下代码   尽量详细点  我是新手。

解决方案 »

  1.   

    Response.Write

    javascript的document.write
      

  2.   


    <asp:Repeater ID="rpt" runat="server">
         <HeaderTemplate>
                 <table>
                     <tr><th>用户名</th></tr>
         </HeaderTemplate>
         <ItemTemplate>
                <tr>
                    <td><%#Eval("UserName")%></td>
                </tr>
         </ItemTemplate>
         <FooterTemplate>
              </table>
         </FooterTemplate>
    </asp:Repeater>using(SqlConnection con = new SqlConnection("Data Source=.;uid=sa;pwd=sa;Database=NorthWind"))
    {
        string strSQL = "select * from Users";
        SqlDataAdapter da  = new SqlDataAdapter(strSQL,con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        this.rpt.DataSource = ds;
        this.rpt.DataBind();
    }
      

  3.   

    你可以直接用一个gridview控件让他显示出来啊,只要数据库中有的数据都可以显示出来,要详细代码的话说一声
      

  4.   

    先写SQL语句 查出 你要显示的内容 GetCon()<asp:DataList ID="DataList1" runat="server" >
                    <ItemTemplate>
                    
                    <asp:Label ID="Label1" runat="server" Text=‘<%#GetCon(Eval("CONTENTS"))%>’></asp:Label>
                     
                    </ItemTemplate>
                    
                </asp:DataList>
      

  5.   

    ...我晕,拖个GridView,绑定数据源,然后一步步做,最简单的了,或者把你这张表传出来到datatable里,然后调值吧,
      

  6.   


      前台:
           <asp:Repeater ID="rptUser" runat="server" onitemcommand="rptUser_ItemCommand">
                <HeaderTemplate>
                   <table>
                       <tr>
                          <th>用户ID</th>
                          <th>用户名</th>
                          <th>联系方式</th>
                          <th>操作</th>
                       </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                       <td>
                         <%#Eval("ID") %>
                       </td>
                       <td>
                         <%#Eval("UserName") %>
                       </td>
                       <td>
                         <%#Eval("Phone") %>
                       </td>
                       <td>
                         <asp:LinkButton ID="lbtnDelete" runat="server" CommandName="delete" CommandArgument='<%#Eval("ID") %>' OnClientClick="return confirm('确定删除?')">删除</asp:LinkButton>
                       </td>
                    </tr>
                </ItemTemplate>
               <FooterTemplate>
                   </table>
               </FooterTemplate>
             </asp:Repeater>
       后台:        protected void rptUser_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();
            if (string.IsNullOrEmpty(id)) return;
            switch (e.CommandName)
            {
                case "delete":
                    this.Delete(id);
                    break;
            }
        }    private bool Delete(string id)
        {
            SqlConnection conn = new SqlConnection("Data Source=.;uid=sa;pwd=sa;Database=NorthWind");
            string sql = "delete from User where id=" + id;
            SqlCommand command = new SqlCommand(sql, conn);
            conn.Open();
          int result=  command.ExecuteNonQuery();
          conn.Close();
          if (result > 0)
              return true;
          else
              return false;
        }
        private void LoadData()
        {
            SqlConnection conn = new SqlConnection("Data Source=.;uid=sa;pwd=sa;Database=NorthWind");
            string sql = "select * from User";
            SqlDataAdapter da = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            rptUser.DataSource = ds;
            rptUser.DataBind();
        }
    有可能有错误,LZ原谅,新手。。
      
      

  7.   

    其实网上有很多例子,你可以照着试做一下,我大概做了一个你看看
    前台
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                            ForeColor="#333333" GridLines="None" 
                            >
                            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                            <Columns>
                                <asp:BoundField DataField="身份证号码" HeaderText="用户ID" ReadOnly="True" />
                                <asp:BoundField DataField="姓名" HeaderText="用户姓名" />
                                <asp:BoundField DataField="员工性别" HeaderText="性别" />
                                <asp:BoundField DataField="家庭住址" HeaderText="家庭住址" />                           
                                <asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
                            </Columns>
                            <RowStyle ForeColor="#000066" />
                            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                        </asp:GridView>
    后台
     string strCon = "Data Source=(local);Database=数据库名;Uid=帐号;Pwd=密码";
            protected void Page_Load(object sender, EventArgs e)
            {
                Bind();
            }
            public void Bind()
            {
                using (SqlConnection con = new SqlConnection(strCon))
                {
                    string strSQL = "select * from Users";
                    SqlDataAdapter da = new SqlDataAdapter(strSQL, con);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    this.GridView1.DataSource = ds;
                    this.GridView1.DataBind();
                }
            }        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
            {
                string sqlstr = string.Format(@"delete from 表 where  条件ID='{0}'", GridView1.DataKeys[e.RowIndex].Value.ToString());
                SqlConnection sqlcon = new SqlConnection(strCon);
                SqlCommand sqlcom = new SqlCommand(sqlstr, sqlcon);
                sqlcon.Open();
                sqlcom.ExecuteNonQuery();
                sqlcon.Close();
                Bind();
            }
    你可以试一试,我没有测试
      

  8.   

    以上太复杂估计你也看不懂,直接在控件里拖一个GridView,然后手动选下数据源,在控件属性中启用分页,启用编辑,启用删除,中文能看懂吧。