要求代码生成DATALIST,绑定数据库中的表或者记录集。
我会在最快的时间内结帖。回复者都得分~
我会在最快的时间内结帖。回复者都得分~
解决方案 »
- Repeater控件的用法
- 【分享】推荐个找代码示例的VS 插件
- webservice
- asp.net程序员都需要掌握哪些技术
- 为什么我的MCV没有RenderView、ReadFromRequest方法
- SQL Server 2005 跟SQL Server Express 2005 的连接字符串是不是不一样?
- DB2取数据问题,求解 请高手解惑
- 如何用DataReader从数据访问层返回查询的数据集?
- 有关webform1.aspx的发布.....
- .NET空间被删除,极度郁闷~ 散分。内容将全部转移到http://xml.sz.luohuedu.net/
- 同样的程序,为何每台电脑的界面大小不一致呢?
- 关于显示提示信息的问题
<ItemTemplate>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" height="186" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="1">
<!--DWLayoutTable-->
<tr>
<td width="100%" height="185" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100%" height="25" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="50" height="25" valign="top"><img src="../image/cz3.GIF" width="50" height="25"></td>
<td width="564" valign="middle" background="../image/cz4.GIF" align="right">顺序是:<a style="COLOR: #ff0000"><%#DataBinder.Eval(Container,"DataItem.shunxu")%></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="160" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="210" height="160" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="2">
<!--DWLayoutTable-->
<tr>
<td width="40" height="16"> </td>
<td width="135"> </td>
<td width="35"> </td>
</tr>
<tr>
<td height="100"></td>
<td valign="middle" align="center"><img src='../<%=Session["diqu"].ToString()%>/<%=Session["shixian"].ToString()%>/<%=Session["username"].ToString()%>/image/<%# DataBinder.Eval(Container, "DataItem.tupian") %>'></td>
<td></td>
</tr>
<tr>
<td height="12"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="32" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="210" height="16" valign="middle" align="center" class="7"><font color="#000000"><%# DataBinder.Eval(Container, "DataItem.tpshuoming") %></font></td>
</tr>
<tr>
<td height="16" valign="middle" align="center" class="7"><font color="#CC0000"><%# DataBinder.Eval(Container, "DataItem.tpshuoming2") %>
</font>
</td>
</tr>
<!--DWLayoutTable-->
</table>
</td>
</tr>
</table>
</td>
<td width="404" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="3">
<!--DWLayoutTable-->
<tr>
<td width="404" height="24"> </td>
</tr>
<tr>
<td height="100" valign="top" class="4"><font color="#333333"><%# DataBinder.Eval(Container, "DataItem.neirong") %>
</font>
</td>
</tr>
<tr valign="middle">
<td height="35" colspan="4" align="right">
<asp:LinkButton Runat="server" ID="lbtn_edit" CommandName="edit">
<asp:Image ImageUrl="../image/cz1.gif" Runat="server" ID="Image2"></asp:Image>
</asp:LinkButton>
<asp:LinkButton Runat="server" ID="lbtn_del" CommandName="del">
<asp:Image ImageUrl="../image/cz2.gif" Runat="server" ID="Image3"></asp:Image>
</asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>
http://www.aspcool.com/lanmu/browse1.asp?ID=697&bbsuser=asp
<ItemTemplate>
<table width="572px" cellSpacing="1" cellPadding="1" border="1">
<tr>
<td style="FONT-SIZE: x-small; COLOR: gray; FONT-FAMILY: 宋体">发送者:
<asp:Label ID="Label9" Runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"sender")%>' Font-Size="x-small" Font-Name="宋体">
</asp:Label></td>
<td style="FONT-SIZE: x-small; COLOR: maroon; FONT-FAMILY: 宋体">发送时间:
<asp:label id="Label8" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"sendtime")%>' Font-Size="x-small" Font-Names="宋体">
</asp:label></td>
<td style="FONT-SIZE: x-small; COLOR: blue; FONT-FAMILY: 宋体">
<asp:LinkButton id="LinkButton3" runat="server" CommandName="reply">回复</asp:LinkButton></td>
<td style="FONT-SIZE: x-small; COLOR: blue; FONT-FAMILY: 宋体">
<asp:LinkButton id="LinkButton4" Runat="server" CommandName="delete">删除</asp:LinkButton></td>
</tr>
<tr>
<td style="FONT-SIZE: x-small; FONT-FAMILY: 宋体" colspan="4"><%#DataBinder.Eval(Container.DataItem,"message")%></td>
</tr>
</table>
<br>
</ItemTemplate>
</asp:datalist><BR>
http://www.aspcool.com/lanmu/browse1.asp?ID=697&bbsuser=asp
在IE里输入
ms-help://MS.NETFrameworkSDKv1.1.CHS/cpgenref/html/cpcondatalistwebservercontrol.htm
建议:学会看微软的帮助文档!
11点结帖
Implements ITemplate
Shared itemcount As Integer = 0
Dim TemplateType As ListItemType Sub New(ByVal type As ListItemType)
TemplateType = type
End Sub Sub InstantiateIn(ByVal container As Control) _
Implements ITemplate.InstantiateIn
Dim lc As New Literal()
Select Case TemplateType
Case ListItemType.Header
lc.Text = "<TABLE border=1><TR><TH>Items</TH></TR>"
Case ListItemType.Item
lc.Text = "<TR><TD>Item number: " & itemcount.ToString _
& "</TD></TR>"
Case ListItemType.AlternatingItem
lc.Text = "<TR><TD bgcolor=lightblue>Item number: " _
& itemcount.ToString & "</TD></TR>"
Case ListItemType.Footer
lc.Text = "</TABLE>"
End Select
container.Controls.Add(lc)
itemcount += 1
End Sub
End Class
ByVal e As System.EventArgs) Handles MyBase.Load
Repeater1.HeaderTemplate = New MyTemplate(ListItemType.Header)
Repeater1.ItemTemplate = New MyTemplate(ListItemType.Item)
Repeater1.AlternatingItemTemplate = _
New MyTemplate(ListItemType.AlternatingItem)
Repeater1.FooterTemplate = New MyTemplate(ListItemType.Footer)
SqlDataAdapter1.Fill(DsCategories1)
Repeater1.DataBind()
End Sub
fmj1980(源)
我以前用的VB,现在用VB.NET+ASP.NET C# 也能看懂。HTML实在没学过~
<ItemTemplate>
html:
<asp:HyperLink id="Hyperlink2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Pro_name"," {0}") %>' NavigateUrl='<%#DataBinder.Eval(Container.DataItem, "pro_id","product.aspx?id={0}")+ "&pro_type="+DataBinder.Eval(Container, "DataItem.Pro_type")%>'>
</asp:HyperLink>
</ItemTemplate>
</asp:datalist>
cs:
/**************************************显示产品列表***********************/
if(!Page.IsPostBack)
{
string pro_id=Request.QueryString["id"];
pro_name=Request.QueryString["pro_type_name"];
if(pro_id== null|| pro_name== null)
{
Response.Redirect("default.aspx");
}
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConectionString"]);
SqlDataAdapter myCommand =new SqlDataAdapter("pro_detail",conn);
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parameter_proid=new SqlParameter("@pro_id",SqlDbType.Int,4);
parameter_proid.Value=Int32.Parse(pro_id);
myCommand.SelectCommand.Parameters.Add(parameter_proid);
try
{
if (conn.State.ToString()=="Closed")
{
conn.Open();
}
DataSet ds = new DataSet();
myCommand.Fill(ds);
Data_pro_detail.DataSource=ds;
Data_pro_detail.DataBind();
myCommand.Dispose();
}
catch(Exception ex)
{
//Response.Redirect("Error_page.aspx?Error=invalid user!");
Response.Write(ex.Message);
}
finally
{
if (conn.State.ToString()=="Open")
{
conn.Close();
conn.Dispose();
}
}