Look.Visible=true; int InvMenuId=Convert.ToInt32(((Label)e.Item.FindControl("Label1")).Text); Session["bmpid"]=InvMenuId.ToString(); SqlCommand SumCmd=new SqlCommand("select sum(investigateCounts) as invsum from investigate where InvMenuId="+InvMenuId,Conn); SqlDataReader invObj=SumCmd.ExecuteReader(); invObj.Read(); InvSum=Convert.ToInt32(invObj["invsum"].ToString()); invObj.Close();
Cmd.CommandText="select * from InvMenu where InvMenuId="+InvMenuId; Cmd.CommandType=CommandType.Text; LookInvMenu.DataSource=Cmd.ExecuteReader(CommandBehavior.CloseConnection); LookInvMenu.DataBind(); Conn.Open(); LabelCounts.Text="总票数:"+InvSum; SqlCommand investigateCmd=new SqlCommand("select * from investigate where InvMenuId="+InvMenuId,Conn); repimg.DataSource=investigateCmd.ExecuteReader(CommandBehavior.CloseConnection); repimg.DataBind();
} int img=1; public void image() { Response.Write(img); if(img>7) { img=1; } img+=1; }
public string gets(string counts) { int coun=Convert.ToInt32(counts); return (coun*100/InvSum).ToString(); }
<asp:Repeater id="repimg" Runat="server">
<ItemTemplate>
<TD valign=bottom>
<TABLE id="Table13" cellSpacing="1" cellPadding="1" border="0" width=100% >
<TR>
<TD><img src='../img/<%image();%>.jpg' height='<%# gets((DataBinder.Eval(Container.DataItem,"investigateCounts")).ToString())%>',width=20 ></TD>
</TR>
<TR>
<TD><%# DataBinder.Eval(Container.DataItem,"investigateItem")%><br>
票数:<%# DataBinder.Eval(Container.DataItem,"investigateCounts")%><br>
百分比:<%# gets((DataBinder.Eval(Container.DataItem,"investigateCounts")).ToString())%>%</TD>
</TR>
</TABLE>
</TD>
</ItemTemplate>
</asp:Repeater>
private void rep_history_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
Look.Visible=true;
int InvMenuId=Convert.ToInt32(((Label)e.Item.FindControl("Label1")).Text);
Session["bmpid"]=InvMenuId.ToString();
SqlCommand SumCmd=new SqlCommand("select sum(investigateCounts) as invsum from investigate where InvMenuId="+InvMenuId,Conn);
SqlDataReader invObj=SumCmd.ExecuteReader();
invObj.Read();
InvSum=Convert.ToInt32(invObj["invsum"].ToString());
invObj.Close();
Cmd.CommandText="select * from InvMenu where InvMenuId="+InvMenuId;
Cmd.CommandType=CommandType.Text;
LookInvMenu.DataSource=Cmd.ExecuteReader(CommandBehavior.CloseConnection);
LookInvMenu.DataBind();
Conn.Open();
LabelCounts.Text="总票数:"+InvSum;
SqlCommand investigateCmd=new SqlCommand("select * from investigate where InvMenuId="+InvMenuId,Conn);
repimg.DataSource=investigateCmd.ExecuteReader(CommandBehavior.CloseConnection);
repimg.DataBind();
}
int img=1;
public void image()
{
Response.Write(img);
if(img>7)
{
img=1;
}
img+=1;
}
public string gets(string counts)
{
int coun=Convert.ToInt32(counts);
return (coun*100/InvSum).ToString();
}
图示:
----------------------------------
| |
| ---------------------------- |
| | | |
| | | |
| ---------------------------- |
| |
----------------------------------
外框内从左到右对齐,并设定外框的长度(比如100PX)
内框的长度设为百分比(比如50%)
这样1%相当于1PX使用上面的原理.在不同的情况下改变内框的长度的百分比(从1%~100%)
int val=int.Parse(this.TextBox1.Text);
TD2.Width=val.ToString()+"%";
TD2.BgColor="#FF0000";件运行