我使用Dim distinctDT As DataTable = dt.DefaultView.ToTable(True, "unit")
Msgbox(distinctDT.Rows.Count)
从generic handler
数据库获取图像我使用此代码对图像进行编码..
null
string Key= Request.QueryString["Key"].ToString();
Session["KeyImage"] = Key;
这是我的控制器图片
public void ProcessRequest(HttpContext context)
{
string Key= Request.QueryString["Key"].ToString();
string ConnectionString = @"Server=MYSQL5011.Smarterasp.net;Database=db_9d6c52_ahmed;Uid=9d6c52_ahmed;Pwd=123123123;";
MySqlConnection GetConnection = new MySqlConnection(ConnectionString);
GetConnection.Open();
string VoiceorScreenSearch = "Select * From User where User_Stat=@UserStat";
MySqlCommand Comand = new MySqlCommand(VoiceorScreenSearch, GetConnection);
Comand.Parameters.AddWithValue(@"UserStat",Key);
MySqlDataAdapter DA = new MySqlDataAdapter(Comand);
DataTable DT = new DataTable();
DA.Fill(DT);
byte[] Image = (byte[]) DT.Rows[0][1];
context.Response.ContentType = "Image/jpg";
context.Response.ContentType = "Image/jpeg";
context.Response.ContentType = "Image/PNG";
context.Response.BinaryWrite(Image);
context.Response.Flush();
}
这是我的<asp:Image ID="Image1" ImageUrl="HandlerImage.ashx" runat="server"></asp:Image>
,我可以在那里检索我的load page
公众,因为我试图通过它来固有!但我没有用的东西!
Query
任何想法我将不胜感激..谢谢
答案 0 :(得分:1)
实际上你忘记了控制器中的Key
它就像是
<asp:Image OnLoad="Image1_Load2" ID="Image1" Width="20%" ImageUrl="HandlerImage.ashx?Key='<%Eval("Key")%> CssClass="fancybox" runat="server"></asp:Image>
或者您可以使用此
在页面加载时传递其参数 Image1.ImageUrl = "HandlerImage.ashx?Key=" + Request.QueryString["Key"].ToString();
应该工作:)