Click here to Skip to main content
15,896,730 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I developing a project in asp.net with componentart.grid. Grid displays same values multiple times.Here my database values
C#
Id	CarModel	Email	                 Phone	  query
2	Audi 	     lali.mahesh@gmail.com	123456	  Test 

Here my output in Grid:

CarModel
Email
Phone
Query
http://localhost:21172/mkkia.co.uk/common/images/Grid/asc.gif
Delete

Audi
lali.mahesh@gmail.com
123456
Test
Delete
Audi
lali.mahesh@gmail.com
123456
Test
Delete

I use the following code:
C#
SqlConnection conn;
DataSet ds;
SqlDataAdapter da;
string strSQL = "";
try
{
    ds = new DataSet();
    conn = new SqlConnection(sConnectionString);
    conn.Open();
    SqlCommand cmd = new SqlCommand();
    da = new SqlDataAdapter(cmd);
    cmd.Connection = conn;
    cmd.CommandText = "SP_GETPAGERESULT";
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@Tables", tableName);
    cmd.Parameters.AddWithValue("@PK", pk);
    cmd.Parameters.AddWithValue("@Sort", sSortColumn);
    cmd.Parameters.AddWithValue("@PageNumber", pageNumber);
    cmd.Parameters.AddWithValue("@PageSize", pageSize);
    cmd.Parameters.AddWithValue("@Fields", fields);
    cmd.Parameters.AddWithValue("@Filter", filter);
    cmd.Parameters.AddWithValue("@Group", "");
    da.Fill(ds);
    if (filter != "")
    {
        strSQL = "SELECT COUNT(*) AS TOTALRECORDS FROM " + tableName + " WHERE " + filter;
    }
    else
    {
        strSQL = "SELECT COUNT(*) AS TOTALRECORDS FROM " + tableName;
    }
    DataSet dsCnt;
    dsCnt = SqlHelper.ExecuteDataset(sConnectionString, CommandType.Text, strSQL);
    RecordCount = (int)(dsCnt.Tables[0].Rows[0].ItemArray[0]);
    //RecordCount = (int)(LoadData(strSQL).Tables[0].Rows[0].ItemArray[0]);
    control.Items.Clear();
    control.DataSource = ds;
    control.DataBind();
    control.RecordCount = RecordCount;
    conn.Close();
    conn.Dispose();
    conn = null;

Please any one help me to resolve this
Posted
Updated 13-Nov-13 1:29am
v2
Comments
ZurdoDev 13-Nov-13 8:35am    
Your sql is likely returning the extra rows. Just debug it and find out what is wrong.
Kornfeld Eliyahu Peter 13-Nov-13 12:36pm    
You may show us SP_GETPAGERESULT...
TryAndSucceed 13-Nov-13 16:20pm    
You also might wanna check your filter values.

1 solution

Hi Friends,

I found the answer for it.

Now its working fine.

Thanks all.
 
Share this answer
 
Comments
Nelek 14-Nov-13 8:38am    
If you found the answer, would you mind to use the "improve solution" to add it? It can help other people in the future.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900