Deepak Ratan

Deepak Ratan

  • NA
  • 175
  • 48.7k

How to use INNER Join to select the statement

May 15 2015 12:33 AM
protected void statusgrdview_RowDataBound(object sender, GridViewRowEventArgs e)
{
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
            Label lblPostID = (Label)e.Row.FindControl("lblPostID");
            string postID = lblPostID.Text;
            DataSet ds = new DataSet();
            con.Open();
            stringcm dstr = "select a.comments,b.UName as CreatedBy from TBL_FBComment a inner join TBL_FBLogin b on a.CreatedBy=b.EmpID and             a.CommentID=a.PostID";
            SqlCommand cmd = new SqlCommand(cmdstr, con);
            cmd.Parameters.AddWithValue("@PostID", postID);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            adp.Fill(ds);
            cmd.ExecuteNonQuery();
            con.Close();   
            try
            {
                  ListView inner = e.Row.FindControl("ListView1") as ListView;
                  inner.DataSource = ds.Tables[0];
                  inner.DataBind();
            }
            catch (Exception ex)
            {
                  throw ex;
            }
      }

Answers (7)