一直在报错,真的不知道怎么解决了。

问题遇到的现象和发生背景

我想写一个页面做论坛类型的帖子,我的想法是人们发布的信息给我存储到数据库,我再把数据库的数据调到表格上,但是现在我卡在绑定数据这儿了怎么也写不出来,求帮助。

问题相关代码,请勿粘贴截图

这是aspx文件

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="社区页面.aspx.cs" Inherits="社区页面"  Debug="true" %>
  
<!DOCTYPE html>

<script runat="server">
   /* public void DataListBind()
    {
        pds = op.PageDataListBind(infotype, infokey, Convert.ToInt32(currentpage.Text), 3);
        LinkButton1.Enabled = true;
        LinkButton2.Enabled = true;
        LinkButton3.Enabled = true;
        LinkButton4.Enabled = true;
        if (currentpage.Text == "1")
        {
            LinkButton1.Enabled = false;
            LinkButton2.Enabled = false;
            

        }
            if(currentpage.Text==pds.PageCount.ToString())
        {
            LinkButton3.Enabled = false;
            LinkButton4.Enabled = false;
        }
        lblSumPage.Text = pds.PageCount.ToString();
        DataList2.DataSource = pds;
        DataList2.DataBind();

        
    }

   protected void LinkButton3_Click(object sender, EventArgs e)
    {
        currentpage.Text = (Convert.ToInt32(currentpage.Text) + 1).ToString();
        DataListBind();
    }

    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        currentpage.Text = (Convert.ToInt32(currentpage.Text) - 1).ToString();
        DataListBind();
    }


    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        currentpage.Text = "1";
        DataListBind();
    }

    protected void LinkButton4_Click(object sender, EventArgs e)
    {
        currentpage.Text = pds.PageCount.ToString();
        DataListBind();
    }*/
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript" src="Scripts/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="Scripts/bootstrap.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>社区页面</title>
    <style>
    .send-post
    {
        width:100%;
        margin:auto;
    }
    .post-list{
        width:100%;
        margin:auto;
    }
     .post-list table thead tr td{
         height:40px;
         background-color:pink;
         width:100%;
     }
      .post-list table thead span{
          color:azure;
          padding-right:10px;
      }
    .post-list table tr td{
        border :1px solid #ccc;
    }
        .auto-style1 {
            width: 37px;
            height: 86px;
        }
        .auto-style2 {
            height: 86px;
        }
        .auto-style3 {
            width: 135px;
            height: 86px;
        }
        .auto-style4 {
            width: 42px;
            height: 86px;
        }
        .auto-style5 {
            width: 40px;
            height: 86px;
        }
    </style>
</head>

<body>
    
        <div>
            
            <div class="row">
                <button type="button" class="btn btn-primary">发帖</button>
        <asp:LinkButton ID="LinkButton1" runat="server">发帖</asp:LinkButton>
       </div>
    <div class="post-list">
        <asp:Repeater ID="rpTest" runat="server">
            <HeaderTemplate>
        <table class="table table-condensed">
            <thead>
                <tr>
                    <td colspan="2">
                        <span>全部主题</span>
                        <span>最新</span>
                         <span>热门</span>
                         <span>精华</span>
                         
                    </td>
                    <td>作者</td>
                    <td>回复/查看</td>
                    <td>发表</td>
                    
                </tr>
                 </thead>
            </HeaderTemplate>
                
                    <ItemTemplate>
                    <tr>
                      <td> <asp:Label ID="Label1" runat="server" Text='<%#Eval("id") %>'></asp:Label></td>
                        <td>
                            <asp:Label ID="Label2" runat="server" Text='<%#Eval("type"+"title") %>'></asp:Label></td>
                        <td>
                            <asp:Label ID="Label3" runat="server" Text='<%#Eval("name") %>'></asp:Label></td>
                        <td>
                            <input type="submit" value="查看详情信息" class="btn btn-defualt"  />
                        </td>
                       
                        <td>
                            <asp:Label ID="Label4" runat="server" Text='<%#Eval("sendtime") %>'></asp:Label></td>
                    </tr>
                        </ItemTemplate>
                   <AlternatingItemTemplate>
                    <tr>
                        <td> <asp:Label ID="Label5" runat="server" Text='<%#Eval("id") %>'></asp:Label></td>
                        <td>
                            <asp:Label ID="Label6" runat="server" Text='<%#Eval("type"+"title") %>'></asp:Label></td>
                        <td>
                            <asp:Label ID="Label7" runat="server" Text='<%#Eval("name") %>'></asp:Label></td>
                        <td>
                            <input type="submit" value="查看详情信息" class="btn btn-defualt" />
                        </td>
                       
                        <td>
                            <asp:Label ID="Label8" runat="server" Text='<%#Eval("sendtime") %>'></asp:Label></td>
                    </tr>
                    </AlternatingItemTemplate>
                    <FooterTemplate>
                   
        </table>
                        </FooterTemplate>
        </asp:Repeater>
           
    </div>
            
        </div>
        <div class="row">
                <div class="col-sm-12 col-md-12">
                    当前页码为[<asp:Label ID="currentpage" runat="server" Text="1"></asp:Label>]页
                    总页码[<asp:Label ID="lblSumPage" runat="server" Text="1"></asp:Label>]页
                    <asp:LinkButton ID="LinkButton2" runat="server">首页</asp:LinkButton>
                    <asp:LinkButton ID="LinkButton3" runat="server" >上一页</asp:LinkButton>
                    <asp:LinkButton ID="LinkButton4" runat="server" >下一页</asp:LinkButton>
                    <asp:LinkButton ID="LinkButton5" runat="server">末页</asp:LinkButton>
                </div>
            </div>



       <script>
    </script>
    
</body>

</html>


这是cs文件

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;

public partial class 社区页面 : System.Web.UI.Page
{
    /*protected DataRowCollection drs = null;
    Operation op = new Operation();
    string type = "";*/
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDataToRepeater();
        }
    }
    /* type = Request.QueryString["id"];
     if (!IsPostBack)
     {
         DataBind(type, 1);

     }

     /*string opearID = Request.Form["opearID"];
     string opearCheckState = Request.Form["opearCheckState"];
     if (opearID != null && opearID != "")
     {
         if (opearCheckState != null && opearCheckState != "")
         {
             ChangeCheckState(Convert.ToInt32(opearID), opearCheckState);
             DataBind(type, Convert.ToInt32(currentpage.Text));
         }
         else
         {
             Response.Redirect("DetailInfo.aspx?id=" + opearID);
         }
     }*/
    /*public void ChangeCheckState(int ID, string opearCheckState)
    {
        if (opearCheckState == "True")
        {
            op.UpdateInfo(ID, true);
        }
        else
        {
            op.UpdateInfo(ID, false);
        }
    }*/
    /*public void DataBind(string type, int PageIndex)
    {
        int PageSize = 10;
        int count = 0;

        DataSet ds = op.Selectcontent(type, PageIndex,PageSize);
        int.TryParse(ds.Tables[0].Rows[0][0].ToString(), out count);
        drs = ds.Tables[1].Rows;
        lblSumPage.Text = ((count / PageSize) + ((count % PageSize) > 0 ? 1 : 0)).ToString();
        currentpage.Text = PageIndex.ToString();
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }*/

    private void BindDataToRepeater()
    {

        string strCon = System.Configuration.ConfigurationManager.AppSettings["DefaultConnection"].ToString();
        SqlConnection con = new SqlConnection("ConStr1");
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from t_topic", con);
        SqlDataAdapter sda = new SqlDataAdapter
        {
            SelectCommand = cmd
        };
        DataSet ds = new DataSet();

        sda.Fill(ds, "t_topic");
        rpTest.DataSource = ds.Tables["t_topic"];
        rpTest.DataBind();
        con.Close();
    }
}

运行结果及报错内容

img

img

我的解答思路和尝试过的方法

我尝试过用图一给的方案,但是都会给出图二的效果

我想要达到的结果

实在是不知道怎么办了,