sSql += " from T_A7_015 as a,T_A7_004 as b,T_A7_014 as c,"; sSql += " ("; sSql += " select sum(mm) as mm,F003 from "; sSql += " ("; sSql += " select datediff(mi,A008,getdate()) as mm,A004 as F003 from T_A2_005"; sSql += " ) as aa group by F003"; sSql += " ) as d"; sSql += " where a.F001*=b.F002 and a.F009=1 and a.F020*=c.F006 and a.F001*=d.F003 and b.F007='区域'"; if (DropDownList2.SelectedIndex>0) { if (DropDownList2.SelectedIndex == 1) { sSql += " and (a.F021!='在用' and a.F021!='清洁' or f021 is null)"; } else { sSql += " and a.F021='" + DropDownList2.Items[DropDownList2.SelectedIndex].Text + "'"; } } if (TextBox1.Text == "") { txtqyBack.Text = ""; } if (txtqyBack.Text != "") { sSql += " and a.F020='" + clsBase.funTranSql(txtqyBack.Text) + "'"; }
资源消耗大,似乎不是太好的办法
ListView 只是个容器罢了
html代码
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" RepeatDirection="Horizontal" CellPadding="4" ForeColor="#333333">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3">
<asp:Image ID="imgItem" runat="server" Height="142px" Width="136px" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "图片路径") %>' /></td>
</tr>
<tr>
<td colspan="1" style="height: 16px">
上:</td>
<td style="height: 16px;" colspan="2">
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "上级区域编号") +"|" +DataBinder.Eval(Container.DataItem, "上级区域名称") %>' Width="118px" Height="16px"></asp:Label></td>
</tr>
<tr>
<td colspan="1" style="height: 15px">
本:</td>
<td style="height: 15px" colspan="2">
<asp:Label ID="lbl002" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "区域编号") +"|" +DataBinder.Eval(Container.DataItem, "区域名称") %>' Width="118px" Height="16px"></asp:Label></td>
</tr>
<tr>
<td colspan="1" style="height: 16px">
状:</td>
<td colspan="2" style="height: 16px">
<asp:Label ID="lbl003" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "在用状态") %>' Width="51px" Height="11px"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" Text='<%# DataBinder.Eval(Container.DataItem, "清洁状态") %>' ForeColor="Red" Height="11px" Width="50px"></asp:LinkButton></td>
</tr>
<tr>
<td colspan="1">
人:</td>
<td colspan="2">
<asp:Label ID="lbl004" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "当前人数")+"|" +DataBinder.Eval(Container.DataItem, "容纳人数") %>' Width="118px" Height="16px"></asp:Label></td>
</tr>
<tr>
<td colspan="1" style="height: 19px">
时:</td>
<td colspan="2" style="height: 19px">
<asp:Label ID="lbl005" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "用时") %>' Width="118px" Height="16px"></asp:Label></td>
</tr>
</table>
<asp:Label ID="lblNm" runat="server" Visible="False" Text='<%# DataBinder.Eval(Container.DataItem, "区域内部编号") %>'></asp:Label>
</ItemTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
</asp:DataList>调用下函数
nCol为一行显示的列数private void funInitDataList(int nCol)
{
#region
//****************************************************************************
//SqlDataReader sdr = null;
try
{ string sSql = "";
sSql += "select "; sSql += " a.F001 as 区域内部编号,a.F002 as 区域编号,a.F003 as 区域名称,";
sSql +=" case";
sSql += " when a.F021 ='在用' or a.F021='清洁' then a.F021 ";//???a.F019";
sSql +=" else '可用'"; sSql += " end as 在用状态, ";
sSql += " c.F007 as 上级区域编号,c.F002 as 上级区域名称,";
sSql += " (select count(*) from T_A2_005 as na where na.A004=a.F001) as 当前人数,isnull(a.F007,'不限') as 容纳人数,";
sSql += " d.mm as 用时,";
sSql += " case";
sSql += " when a.F021='清洁' then '设为可用' ";//???a.F019";
sSql += " else ''"; sSql += " end as 清洁状态, ";
if (Button1.Text == "实图")
{
sSql += " case a.F021";
sSql += " when '在用' then '../image/zy.jpg'";
sSql += " when '清洁' then '../image/qj.jpg'";
sSql += " else '../image/ky.jpg'";
sSql += " end as 图片路径";
}
else
{
sSql += " ('../Main/custompage/getPhoto.aspx?Key='+ isnull(b.F002,'')) as 图片路径";
}
sSql += " from T_A7_015 as a,T_A7_004 as b,T_A7_014 as c,";
sSql += " (";
sSql += " select sum(mm) as mm,F003 from ";
sSql += " (";
sSql += " select datediff(mi,A008,getdate()) as mm,A004 as F003 from T_A2_005";
sSql += " ) as aa group by F003";
sSql += " ) as d";
sSql += " where a.F001*=b.F002 and a.F009=1 and a.F020*=c.F006 and a.F001*=d.F003 and b.F007='区域'";
if (DropDownList2.SelectedIndex>0)
{
if (DropDownList2.SelectedIndex == 1)
{
sSql += " and (a.F021!='在用' and a.F021!='清洁' or f021 is null)";
}
else
{
sSql += " and a.F021='" + DropDownList2.Items[DropDownList2.SelectedIndex].Text + "'";
}
}
if (TextBox1.Text == "") { txtqyBack.Text = ""; }
if (txtqyBack.Text != "")
{
sSql += " and a.F020='" + clsBase.funTranSql(txtqyBack.Text) + "'";
}
SqlDataAdapter da = new SqlDataAdapter(sSql, new clsDataBase().funGetConntion()); DataSet ds = new DataSet(); da.Fill(ds);
if (ds.Tables[0].Rows.Count < nCol)
{
DataList1.RepeatColumns = ds.Tables[0].Rows.Count;
}
else
{
DataList1.RepeatColumns = nCol;
}
DataList1.DataSource = ds; DataList1.DataBind();
//处理
//上级区域编号及名称
}
catch (Exception Ex)
{
//if (sdr != null){if (!sdr.IsClosed) sdr.Close();sdr = null;}
new clsBaseNormal().funWriteErrorLog(Ex);
}
finally
{
//if (sdr != null){if (!sdr.IsClosed) sdr.Close();sdr = null;}
}
//****************************************************************************
#endregion
}
按钮列表的表示方法还是没人说到
是没人用这样的方式吗?
类似DELPHI中的DATAWINDOW
ListView里边,想加什么都行。