Sir, i am having text box for id(primary key),
on click of the button i want to display the entire row of id in grid view from database.
on the click of the button it is not showing anything.
below is my code please tel the necessary changes.
.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
public partial class searchu : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlDataSource SqlDataSource1 = new SqlDataSource();
this.Page.Controls.Add(SqlDataSource1);
SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlDataSource1.SelectCommand = "SELECT * FROM users WHERE ElectionId ='" + this.TextBox1.Text.Trim() + "'";
this.GridView1.DataSource = SqlDataSource1;
this.GridView1.DataBind();
this.GridView1.Visible = true;
}
}