我是ASP.Net的新手,我需要一些指导从哪里开始,怎么做? 我读过几篇我在不同网站上发现的文章。但是,有些人没有使用VB代码,而且我对我的C#编码知识没有信心。
我已经从我的数据库中包含了一个表和一个PHP代码,以帮助可视化我想要创建的内容。
------------------------------------------------------------------------------------------
| items_id | items_name | items_description | items_price | items_quantity |
------------------------------------------------------------------------------------------
| 1 | Spoon | Shiny and Silver | 50 | 20 |
| 2 | Fork | Shiny and Silver | 50 | 20 |
| 3 | China | Clean and Polished | 90 | 20 |
------------------------------------------------------------------------------------------
$sql = mysql_query("SELECT * FROM tbl_items");
$productCount = mysql_num_rows($sql);
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["items"];
$name = $row["items_name"];
$description = $row["items_description"];
$price = $row["items_price"];
$quantity = $row["items_quantity"];
$check_pic = 'venues/'.$id.'/'.$id.'.jpg';
if (file_exists($check_pic)) {
$img_src = 'venues/'.$id.'/'.$id.'.jpg';
} else {
$img_src = 'venues/0/0.jpg';
}
$dynamicList .= '<li class="span3">
<div class="thumbnail">
<p><b>'.$name. '</b></p><br />
<img src="'.$img_src.'" alt="" style="box-shadow: 0 2px 3px rgba(0,0,0,0.2);">
<div class="caption">
<p align="center" class="lead" style="color:#053750;"> '.$venue.'</p>
<hr />
<p><b>Description: </b> '.$description. '</p><br />
<p><b>Price: </b> '.$price. '</p><br />
<p><b>Quantity: </b> '.$quantity. '</p><br />
<p><a href="items_details.php?items_id='.$id.'" class="btn btn-info btn-block">Choose</a> </p>
</div>
</div>
</li>';
}
Binding a generic list to a repeater - ASP.NET - 后面的代码是C#,即使在C#到VB转换器的帮助下我很难转换
答案 0 :(得分:0)
从PHP代码到.NET代码的最直接的映射是使用这样的库: http://www.mysql.com/products/connector/
使用MySqlConnection类连接到数据库服务器,使用MySqlCommand类构建查询,使用MySqlDataReader迭代结果并构建标记。
这将使您启动并运行,然后如果您想调查.NET对转发器或其他控件的绑定,您可以从那里开始工作。