Pages

Friday, 2 March 2012

How to Bind The Data to Data List Control In Side The Grid View


protected void grvExpendabael_RowDataBound(object sender, GridViewRowEventArgs e)
    {
     

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            GridView grdFamilymember = (GridView)e.Row.FindControl("grdFamilyMember");
         
           
            SqlCommand cmd = new SqlCommand("GetProductById1", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p1 = new SqlParameter("@CiD", SqlDbType.Int);
            p1.Value = 1;
            cmd.Parameters.Add(p1);
            con.Open();
            cmd.ExecuteNonQuery();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();
            da.Fill(ds, "GetProductById1");
            // galleryDataList.
            DataList dss = (DataList)e.Row.FindControl("galleryDataList");
            dss.DataSource = ds;
            dss.DataBind();
            con.Close();

        }
    }

No comments:

Post a Comment