I have a User Information table which contains
First name
last name
...
When i am fetching the Data from a source into a dataset. It shows the repeated Value in a grid as:
First Name Last Name .... First Name Last Name....
the code as follows:
Utility class
public DataSet GetMember()
{
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cnn = new SqlCommand("selectmember", con))
{
cnn.CommandType = CommandType.StoredProcedure;
using(DataSet ds=new DataSet())
{
try
{
con.Open();
cnn.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cnn);
da.Fill(ds);
}
catch (Exception e)
{
}
return ds;
}
}
}
}
Member.aspx
public void binddata()
{
DataSet ds = new DataSet();
ds = utility.GetMember();
GdMember.DataSource = ds;
GdMember.DataBind();
}
Am i missing any code or i am doing any error. Thanks for any assistance.
Most probably your grid has explicit column templates but in the same time you forgot to set AutoGenerateColumns to false. Thus, the first set of columns comes from templates and the second one is auto generated by the grid based on the structure of the data set.