GridView displaying too much data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • readnlearn
    New Member
    • Aug 2008
    • 15

    GridView displaying too much data

    Hii, in my table I have fields like id1,title,descr iption,category ,posteddate..In my gridview I wish to display title,posteddat e and category. I placed a hyperlink for title field. Now when I click on title it should display the description part which I have entered before. My problem is when I bind the description part to gridview its binding all the data which is present under description but I want only the description part which is entered by that particular user..

    Do I need to do anything with id1 in the query part..Pls let me know

    Here is my code:
    =============== ====


    Code:
    SqlConnection sqlCn = new SqlConnection("User ID=sa;Initial Catalog=harini;Data Source=SYS05");
    DataSet ds;
    
    protected void Page_Load(object sender, EventArgs e)
    {
    
    
    ds = getdataset();
    GridView1.DataSource = ds;
    GridView1.DataBind();
    }
    
    public DataSet getdataset()
    {
    string query = ("SELECT title, category, posteddate FROM tblAdd");
    
    SqlDataAdapter mydap = new SqlDataAdapter(query, sqlCn);
    
    DataSet ds = new DataSet();
    mydap.Fill(ds);
    return ds;
    }
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Please remember to use code tags when posting code.

    MODERATOR

    Now, as to your question, you will need to add a WHERE clause to your query. This is basic SQL. If you don't know how to do this, please find a SQL tutorial and read it. I suggest the one at w3schools.

    Comment

    Working...