我已經綁定了asp頁面的on-load()函數的數據,我可以檢索所有數據,但不幸的是我無法看到圖像。我附上了代碼,請給我一些想法,我該怎麼做?幫助我在網格視圖中顯示圖像。在gridview中顯示來自datatable的圖像
<asp:GridView ID="GridView2" runat="server">
<AlternatingRowStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="#C19E45" ForeColor="White" />
<SelectedRowStyle BackColor="#3333CC" ForeColor="Red" />
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = client.viewClients();
DataTable newdt = new DataTable();//for filtering data
newdt.Columns.Add("id", typeof(string));
newdt.Columns.Add("Name", typeof(string));
newdt.Columns.Add("Father/Husband", typeof(string));
newdt.Columns.Add("Cnic", typeof(string));
newdt.Columns.Add("Occupation", typeof(string));
newdt.Columns.Add("Present_Address", typeof(string));
newdt.Columns.Add("Telephone", typeof(string));
newdt.Columns.Add("Phone", typeof(string));
newdt.Columns.Add("Email", typeof(string));
newdt.Columns.Add("Permanent_address", typeof(string));
newdt.Columns.Add("Nominee_name", typeof(string));
newdt.Columns.Add("Nominee_address", typeof(string));
newdt.Columns.Add("Nominee_cnic", typeof(string));
newdt.Columns.Add("nominee_no", typeof(string));
newdt.Columns.Add("Image", typeof(string));
newdt.Columns.Add("registeration_no", typeof(string));
foreach (DataRow row in dt.Rows)
{
DataRow nrow = newdt.NewRow(); //creating newRow
// byte[] imgarray = (byte[])row["image"];
// System.Drawing.Image img = client.byteArrayToImage(imgarray);
nrow["id"]=row["id"];
nrow["Name"] = row["name"];
nrow["Father/Husband"] = row["relation_of"];
nrow["Cnic"] = row["applicant_cnic"];
nrow["Occupation"] = row["occupation"];
nrow["Present_Address"] = row["present_address"];
nrow["Telephone"] = row["telephone"];
nrow["Phone"] = row["mobile"];
nrow["Email"] = row["email"];
nrow["Permanent_address"] = row["permanent_address"];
nrow["Nominee_name"] = row["nominee_name"];
nrow["Nominee_address"] = row["nominee_address"];
nrow["Nominee_cnic"] = row["nominee_cnic"];
nrow["nominee_no"] = row["nominee_no"];
nrow["Image"] = row["image"];
nrow["registeration_no"] = row["registeration_no"];
newdt.Rows.Add(nrow);
}
GridView2.DataSource = newdt;
GridView2.DataBind();
}