Hey i want to ask that,suppose in HTML table cell...I insert Hyperlink....Is that possible to write the code for that hyperlink...Cz if the iamges are static,HTML table is better option than Gridview,I thk so????

Recommended Answers

All 4 Replies

Is it possible to extract the database data & show that data into HTML table..

YES POSSIBLE.
USE RESPONSE.WRITE/ADD A LITERAL CONTROL IN YOUR PAGE & THEN PASTE TABLE HTML WILL RESOLVE YOUR PROBLEM.

LET YOU READ DATA IN THE BELOW WAY:

SqlCommand cmd = new SqlCommand();
            cmd.Connection = Conn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = sSPName;
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataTable dt = new DataTable(cmd.CommandText);
            da.Fill(dt);

SO NOW YOU GOT A DATATABLE. LOOP THROUGH THE DATATABLE 7 GENERATE TABLE CONTENTS LIKE:

STRING STABLE="<TABLE><Tr>....</TR>";
foreach (DataRow oItem in dt.Rows)
        {
            STABLE=STABLE+"<TR><TD>";
            STABLE=STABLE+OITEM["COLNAME"];
            STABLE=STABLE+"</TD></TR>";
         } 
STABLE=STABLE+"</TABLE>";

NOW WRITE THIS STRING IN PAGE OR IN LITERAL.
IF YOUR TABLE CONTENTS WILL BE LONG THEN USE STRING BUILDER INSTEAD OF ABOVE WAY.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.