I am new to asp.net, and what I want to know is how to bind data directly into a custom div without using things such as data grid or any other thing, let's say I want to bind a description for something stored in my sql DB.
In PHP i used to do this:
<p>
<?php echo $row_RecordSetName['col']; ?>
</p>
But how to do in asp.net using C# in a webform?
I tried to do it in a dataset thing like so but it keeps giving errors:
<p>
<%= Dataset.DB[0].colNAME.ToString() %>
</p>
as well as i tried doing the following stupid way :
try
{
for (int i = 1; i < 7; i++)
{
SqlConnection cn = new SqlConnection("Data Source=server;Initial Catalog=db;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT * FROM mallsdb where mall_un='" + i + "'", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
MallsDS tds = new MallsDS();
da.Fill(tds, tds.Tables[0].TableName);
string MallPIC = Convert.ToString(tds.mallsdb[0].mall_pic);
string MallNAME = Convert.ToString(tds.mallsdb[0].mall_name);
string MallUn = Convert.ToString(tds.mallsdb[0].mall_un);
string MallDESP;
string check_desp = Convert.ToString(tds.mallsdb[0].mall_desp);
if (check_desp.Length < 50)
{
MallDESP = check_desp;
}
else
{
string under = check_desp.Substring(0, 30);
MallDESP = under + "....";
}
Result[i] = "<div class='malls'>" + "<img src='images/" + MallPIC + "' width='250' height='250' />" + "<a class='namer' href='malls_private.aspx?mall_un=" + MallUn + "'><h1>" + MallNAME + "</h1></a><p>" + MallDESP + "</p></div>";
}
}
catch (Exception ex)
{
Response.Write("Error:" + ex.ToString());
}
Label1.Text = Result[1];
Label2.Text = Result[2];
Label3.Text = Result[3];
Label4.Text = Result[4];
Label5.Text = Result[5];
Label6.Text = Result[6];