abdujalil  chuliev

abdujalil chuliev

  • 1.2k
  • 400
  • 38.8k

bindgrid

Sep 5 2015 9:44 AM
I want this BindGrid() to return bunch of images in my GridView, unfortunately it is giving single image from the last column cell.
private void BindGrid()
{ MySqlConnection con = new MySqlConnection(constr);
MySqlCommand cmd = new MySqlCommand("SELECT * FROM images where Image_ID='"+getImage_ID()+"'", con);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
gvImages.DataSource = dt;
gvImages.DataBind();
}
string getImage_ID()
{ MySqlConnection con = new MySqlConnection(constr);
con.Open();
MySqlCommand cmd = new MySqlCommand("Select Arrive_Img_ID,Leave_Img_ID from register where Students_ID='" + getStudent_ID() + "'");
cmd.Connection = con;
MySqlDataReader reader = cmd.ExecuteReader();
string i = null;
while (reader.Read())
{
i = reader["Arrive_Img_ID"].ToString();
i = reader["Leave_Img_ID"].ToString();
}
reader.NextResult();
reader.Close();
return i;
}
I have struggled for many days with this.
I am not sure if my "string getImage_ID" method is just poorly designed in my case or there is something basic I am missing.
Any examples of how you usually handle this would be appreciated. Thanks.

Answers (3)