下一步按钮仅将一个记录上移,下一步单击不起作用(C#)

时间:2018-11-13 13:31:14

标签: c#

在下面的代码中,我使用lblID.text中的当前ID选择下一个记录ID,以浏览记录。但是,当我第一次单击next按钮时,它可以工作并移至下一个id,但是第二次及以后的单击均不起作用。我需要帮助(下面是代码)

protected void btnNext_Click(object sender, EventArgs e)
        {

            int currentrowID = Convert.ToInt32(lblID.Text);
            SqlConnection con = new SqlConnection(connection);
            string commandtext = "SELECT TOP 1 * FROM Outwards WHERE id > @currentrowID ORDER BY id";
            SqlCommand command = new SqlCommand(commandtext, con);
            command.Parameters.AddWithValue("@currentrowID", currentrowID);
            con.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                lblID.Text = reader["id"].ToString();
                lblPayerBankRoutNo.Text = reader["PayorBankRoutNo"].ToString();
                lblAccountNumber.Text = reader["AccountNo"].ToString();
                lblTransCode.Text = reader["TransCode"].ToString();
                lblAmount.Text = reader["Amount"].ToString();

                //showing front image
                byte[] frontimagebyte = (byte[])reader["FImage"];
                RadBinaryImage1.ImageUrl = "data:image;base64," + Convert.ToBase64String(frontimagebyte);

                //showing front image
                byte[] rearimagebyte = (byte[])reader["RImage"];
                RadBinaryImage2.ImageUrl = "data:image;base64," + Convert.ToBase64String(rearimagebyte);
            }

            reader.Close();
            con.Close();
        }

0 个答案:

没有答案