Sam123

Sam123

  • NA
  • 45
  • 2.2k

c# developement

Apr 5 2020 1:02 AM
 Question - The below code is succesfully pulling the data from Activity table but while storing the data and displaying using gridview instead of showing name it is showing the ID. 
 
public void BindSupportActivity_Activity()
{
try
{
using (SqlConnection sqlCon = new SqlConnection(@"Data Source=IN5CG9299JKK;Initial Catalog=table;Trusted_Connection=True"))
{
{
sqlCon.Open();
string query = "select * from mActivity";
SqlDataAdapter sqladpt = new SqlDataAdapter(query, sqlCon);
DataTable dt = new DataTable();
sqladpt.Fill(dt);
Activity.DataSource = dt;
Activity.DataBind();
Activity.DataTextField = "ActivityName";
Activity.DataValueField = "ID";
Activity.DataBind();
sqlCon.Close();
}
}
Activity.Items.Insert(0, new ListItem("", ""));
}
catch (Exception ex)
{
throw;
}
}
 
 
 
 

Answers (3)