SqlConnection con = new SqlConnection(obj.conString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SHOWDATA";
cmd.Parameters.Add("@Root", SqlDbType.Int).Value = DropDownList2.SelectedValue;
cmd.Connection = con;
try
{
con.Open();
GridView2.EmptyDataText = "No Records Found";
GridView2.DataSource = cmd.ExecuteReader();
GridView2.DataBind();
foreach (GridViewRow row in GridView2.Rows)
{
string id = ((HiddenField)row.Cells[2].FindControl("hnfID")).Value.ToString();
Label lbtsanstha = ((Label)row.Cells[2].FindControl("lblsanstah"));
SqlDataReader rdr = SqlHelper.ExecuteReader(obj.conString, CommandType.Text, "select * from SansthUserDetail where userid='" + id + "'");
while (rdr.Read())
{
string col1Value = rdr["Sanstha"].ToString();
lbtsanstha.Text = lbtsanstha.Text + ' ' + col1Value + ",".ToString();
}
lbtsanstha.Text = lbtsanstha.Text.Substring(0, lbtsanstha.Text.Length - 1);
}
}
catch (Exception ex)
{ throw ex; }
finally
{ con.Close(); con.Dispose(); }
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SHOWDATA";
cmd.Parameters.Add("@Root", SqlDbType.Int).Value = DropDownList2.SelectedValue;
cmd.Connection = con;
try
{
con.Open();
GridView2.EmptyDataText = "No Records Found";
GridView2.DataSource = cmd.ExecuteReader();
GridView2.DataBind();
foreach (GridViewRow row in GridView2.Rows)
{
string id = ((HiddenField)row.Cells[2].FindControl("hnfID")).Value.ToString();
Label lbtsanstha = ((Label)row.Cells[2].FindControl("lblsanstah"));
SqlDataReader rdr = SqlHelper.ExecuteReader(obj.conString, CommandType.Text, "select * from SansthUserDetail where userid='" + id + "'");
while (rdr.Read())
{
string col1Value = rdr["Sanstha"].ToString();
lbtsanstha.Text = lbtsanstha.Text + ' ' + col1Value + ",".ToString();
}
lbtsanstha.Text = lbtsanstha.Text.Substring(0, lbtsanstha.Text.Length - 1);
}
}
catch (Exception ex)
{ throw ex; }
finally
{ con.Close(); con.Dispose(); }
No comments:
Post a Comment