开发者

Load the information in Grid View from SQL

开发者 https://www.devze.com 2022-12-25 10:47 出处:网络
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.

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(); 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消