I need to load the database values into the grid view by checking the attribute "id".
If the id value which 开发者_如何学CI entered is equal to database, then it'll load in the grid view.
Help me to do that
You have to loop through the records on the backend and parse out the records you don't want to show before you bind to the gridview; it's much easier that way.
HTH.
You might want to try to add this to the code-behind module
void Page_load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
CreateGrid();
}
}
void CreateGrid()
{
DataSet ds = new DataSet();
string str = "select * from Personal where id='" + TextBox1.Text + "'";
SqlDataAdapter da = new SqlDataAdapter(str, con);
da.Fill(ds, "Personal");
GridView1.DataSource = ds.Tables["Personal"].DefaultView;
GridView1.DataBind();
}
精彩评论