如何从sql表中为行提升数据表 [英] How to raise a datalist for rows from sql table
本文介绍了如何从sql表中为行提升数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下datalist代码中,我无法限制用于表格中item_desc的label1
的宽度。我将宽度和高度设置为33但没有效果。
重复数据显示在一行中。任何人都可以指导我吗?
In the following code for datalist I am unable to restrict the width of the label1
used for "item_desc" from a table. I made the width and height to 33 but no effect.
The retrived data is displayed in a single line. Can anyone guide me?
<head runat="server">
<title></title>
<style type="text/css">
#form1 {
height: 466px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
Datalist testing
</h1>
</div>
<div id="content">
<div class="item content">
<br />
<asp:DataList ID="Datalist1" runat="server" DataKeyField="item_code" RepeatDirection="Horizontal"
RepeatLayout="Table"
datasourceid="sqldatasource1">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
Item code:
<asp:Label Id="Itmcodelbl" runat="server" Text='<%#Eval("item_code") %>'>
</asp:Label>
<br />
Item Name:
<asp:Label Id="Itmnamelbl" runat="server" Text='<%#Eval("item_name") %>'>
</asp:Label>
<br />
<table Width="33" >
<tr>
<td Width="33" Height="33" >
Particulars:
<asp:Label Id="Label1" runat="server" Text='<%#Eval("item_desc") %>'
Width="33" Height="33">
</asp:Label>
</td>
</tr>
</table>
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="sqldatasource1" runat="server"
ConnectionString="<%$Connectionstrings:prassidhiConnectionString %>"
SelectCommand="SELECT [item_code], [item_name],[item_desc] FROM [item] ">
</asp:SqlDataSource>
<br />
<div id="footer">
<p class="left">
All content copyright..
</p>
</div>
</div>
</div>
</form>
</body>
推荐答案
Connectionstrings:prassidhiConnectionString %>
SelectCommand = SELECT [item_code],[item_name],[item_desc] FROM [item] >
< / asp:SqlDataSource >
< br / >
< div id = foo ter >
< p class = left >
所有内容版权..
< / p >
< span class =code-keyword>< / div >
< / div >
< / div >
< / form >
< / body >
Connectionstrings:prassidhiConnectionString %>" SelectCommand="SELECT [item_code], [item_name],[item_desc] FROM [item] "> </asp:SqlDataSource> <br /> <div id="footer"> <p class="left"> All content copyright.. </p> </div> </div> </div> </form> </body>
您好,
将以下事件添加到您的datalist
Hi,
add below event to your datalist
private void Datalist1_ItemCreated(Object s, DataListItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Width = Unit.Parse("50%");
}
}
这里你可以设置所需物品的宽度属性
here you can set width property for your required item
这篇关于如何从sql表中为行提升数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文