I am getting the contents on my website from database using SQL Stored Procedure (C#).

Now, I want to change the output look with XML / XSLT. How can I do this?

Something like this http://forums.asp.net/t/1230093.aspx/1 but am not sure how to go about it, am new to C# .NET

My sample code.

SqlConnection objConn = new SqlConnection();
        objConn.ConnectionString = "server=\\SQL2005;database=********;Integrated Security=false;user=********;pwd=*********;";
        SqlCommand objCmd = new SqlCommand("getContent", objConn);
        objCmd.CommandType = CommandType.StoredProcedure;

        SqlDataAdapter result = new SqlDataAdapter(objCmd);

        DataSet selectResults = new DataSet();
        result.Fill(selectResults); // get dataset


        foreach (DataRow row in selectResults.Tables[0].Rows)
            Literal1.Text = (selectResults.Tables[0].Rows[0]["title"].ToString() + "<br />" + selectResults.Tables[0].Rows[0]["created_at"].ToString() + "<br />" + selectResults.Tables[0].Rows[0]["summary"].ToString() + "<br />" + selectResults.Tables[0].Rows[1]["title"].ToString() + "<br />" + selectResults.Tables[0].Rows[1]["created_at"].ToString() + "<br />" + selectResults.Tables[0].Rows[1]["summary"].ToString() + "<br />" + selectResults.Tables[0].Rows[2]["title"].ToString() + "<br />" + selectResults.Tables[0].Rows[2]["created_at"].ToString() + "<br />" + selectResults.Tables[0].Rows[2]["summary"].ToString());  


<asp:Literal ID="Literal1" runat="server"></asp:Literal>

Recommended Answers

All 2 Replies

If you want to alter the way the results look on the page you can always include HTML in your literal control and apply CSS classes. Much easier than XSLT.
Or do you want to change the database output to XML?

Thank you very much hericles.

I don't necessarily have to output it as XML but I think it will be the only way to add somethings I need like making my content READ MORE, I just want to alter the way the result look.


What I have currently:

Test Item 1
12/5/2011 8:02:07 PM
Test Item 1 Summary
Test Item 2
12/5/2011 8:48:36 PM
Test Item 2 Summary
Test Item 3
12/5/2011 8:49:57 PM
Test Item 3 Summary

What I need:

Article 1
5 December, 2011
Summary text
Read More >> (here will take me to the full description)

How can I go about it?

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.