Results 1 to 9 of 9

Thread: [RESOLVED] Getting SQL data into Label not DataGrid

Threaded View

  1. #1

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Resolved [RESOLVED] Getting SQL data into Label not DataGrid

    I do not understand why every tutorial website that I go to uses the DataGrid control as an example.

    Is this standard, should I also be using this control in my project?

    I have a page called Article.aspx. It displays one image and one article that is pulled from a database.

    I want to display this data using: <asp:Image src="image link"> and <asp:label text="body of the article"> not as a <asp:datagrid>

    I have no problem with the DataGrid control, it just seems like overkill since I only need 1 row from the database. I also do not want this information in a grid, I would like to have the power to place it wherever I desired. I.E, I want to put the article image on the left, article title on the top, and the body of the article in the middle of the page... you get the idea.

    Is there something I am missing here? Could one not do something like:

    Code:
        LabelArticleBody.Text = ds.Tables["tblArticle"].Columns[1].???;

    Incase you are interested, this is what my pageload looks like:

    Code:
    protected void Page_Load(Object sender, EventArgs e)
    {
        String strCategoryID;
        String strArticleID;
    
        strCategoryID = Request.QueryString["sci"];
        strArticleID = Request.QueryString["sai"];
        
    	SqlConnection sqlCon = new SqlConnection("private");
    	SqlDataAdapter myCommand = new SqlDataAdapter("SELECT * FROM tblArticle WHERE tblArticle.charArticleID='" + strArticleID + "' AND tblArticle.charCategoryID='" + strCategoryID + "'",sqlCon);
    	
    	DataSet ds = new DataSet();
    	myCommand.Fill(ds, "tblArticle");
    	
    	/* gridArticle.DataSource=ds.Tables["tblArticle"].DefaultView;
    	    gridArticle.DataBind();
                Great for testing but I do not want to use a DataGrid.  
            */
        
        //lblArticleBody.Text = ds.Tables["tblArticle"].???;  -- whats the missing piece? :P
    }
    Last edited by invitro; Aug 17th, 2006 at 06:38 PM. Reason: I said "1 value" rather then "1 row", this was confusing.
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width