Turki
Turki

Reputation:

How can I print a value in my page from Database

How do I display information in my page (take it from DB) in asp.net 2008

Currently I use GridView, but it display the information in a TABLE. I want to display it in a normal line.

for example: I have this table in my DB

http://www.rofof.com/img2/4jpqfn26.gif

alt text http://www.rofof.com/img2/4jpqfn26.gif

I want to print an information in my page as:

You are A and your ID is: 1

without using GridView.

Upvotes: 0

Views: 584

Answers (1)

JoshBerke
JoshBerke

Reputation: 67108

How are you getting your data from the database to your gridview? Also do you want to display only a single record or would you display multiple records?

The Repeater is a great control if you want to display all the records. You can bind it the same way your binding the grid then define your template to render the html however you want.

If you only want to display a single record you could just do this in the code behind of the page. For example:

Page_Load()
{
   if (!IsPostBack) //Make sure this only runs first time we call page
   {
     //Get your data from the DB, can't help here unless 
     //you provide more details. 
       MyData data=....
       myLabel.Text="You are " + data["name"].ToString() ....
   }
}

If you update your question with more details about your data source (are you using a data table custom objects etc...). I can update my answer with a better exampkle

Upvotes: 1

Related Questions