在Repeater中的linkbutton传两个值的方法

前台代码:

<asp:LinkButton ID="btn_Use" runat="server" CausesValidation="False" Text="引用" OnClick="btn_Use_Click" CommandArgument='<%# Eval("PDR_id")+"_"+(Convert.ToInt32(Container.ItemIndex+1) + pageIndex * pageSize) %>'>asp:LinkButton>

 

后台代码:

    //引用

    protected void btn_Use_Click(object sender, EventArgs e)

    {

        string strText = ((LinkButton)sender).CommandArgument.ToString();

        string Sp = "_";

        char[] Char = Sp.ToCharArray();

        string[] strArray = strText.Split(Char);

 

        string PDR_ID = strArray[0].ToString().Trim();

        string num = strArray[1].ToString().Trim();

 

        conn.Open();

 

        SqlCommand cmd = new SqlCommand("select * from PDReply where PDR_ID='" + PDR_ID  + "'", conn);

        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.Read())

        {

            string PDR_content = reader["PDR_content"].ToString().Trim();

            string id = reader["PDR_user_id"].ToString();

            reader.Close();

            conn.Close();

 

            //注:因为用到了BR_Name(id),所以这句一定要放在conn.Close();之后。

            FCKeditor1.Value = "

引用 " + num + " " + BR_Name(id) + 的日志:" + PDR_content + "
";

 

        }

        else

        {

            reader.Close();

            conn.Close();

        }

    }

 

你可能感兴趣的:(ASP.NET)