Bhavesh Vankar

Bhavesh Vankar

  • 753
  • 1.2k
  • 89.3k

In popup modal page record not showing

Jun 19 2021 12:24 PM
string namestring = txtfname.Text + " " + txtmname.Text + " " + txtlname.Text;
//        string firstlastname = txtfname.Text + " " + txtlname.Text;

        if (txtfname.Text != "" && txtlname.Text != "")
        {
            SqlConnection con2 = new SqlConnection(this.con2);
            con2.Open();
            SqlCommand cmd = new SqlCommand("Select NAME,ADDRESS,CITYORVILLAGE,TALUKA,DISTRICT,CONTACTNO From Student_Records where NAME Like '" + namestring + "'", con2);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            sda.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true);
                lblName.Text = dt.Rows[0]["NAME"].ToString();
                lblAddress.Text = dt.Rows[0]["ADDRESS"].ToString();
                lblCityvillage.Text = dt.Rows[0]["CITYORVILLAGE"].ToString();
                lblTaluka.Text = dt.Rows[0]["TALUKA"].ToString();
                lblDistrict.Text = dt.Rows[0]["DISTRICT"].ToString();
                lblContactno.Text = dt.Rows[0]["CONTACTNO"].ToString();

            }

i have wriiten code as below. when the name is exist in table than modal should be open and display details related entered name in textbox. below code is working fine in my another practicle program  but when i try to implement in my main project its not working modal open but record not showing. what to do in this case ?

where is i made mistake ? 

their is also one more query i in table name stored in one column and i have split in textbox from table. 

what to do if only split firstname and lastname from sql to textboxes....

i have split it like " string namestring = txtfname.Text + " " + txtmname.Text + " " + txtlname.Text;"


Answers (3)