Hi All,

I am storing my automation results to sql server and the displaying the results in asp page.

one of result coulmn is for error images(is test case fails it capture the image , for refrence of what went wron during playback) stored in local machine or QA server.


Thanks,

Recommended Answers

All 4 Replies

Use ImageButton and TemplateField - ImageButton has both ImageUrl and PostBackUrl property.

Hi adatapost,
Thanks.

As i am an QA so not much familiar with asp.

using following code(which i searched from net) i could hyperlink the image files name in grid.

But when i click on link it does nothing.

string ErrorScreen = e.Row.Cells[8].Text;
                       
            if (ErrorScreen != "")
            {
                HyperLink hlink = new HyperLink();
                hlink.ID = ErrorScreen;
                hlink.NavigateUrl = "C:/Silk/" + ErrorScreen;
                hlink.Text = ErrorScreen.ToString();
                e.Row.Cells[8].Controls.Add(hlink);
            }

All suggestion/help or sample code every much appreciated from all

Thanks.

hi..

Check This code and modify it..i have used a datagrid with template field.

#region To Set Image links

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    HyperLink chk2 = (HyperLink)(GridView1.Rows[i].Cells[5].FindControl("hypImage"));
                    Label lbl = (Label)(GridView1.Rows[i].Cells[4].FindControl("lblPrId"));
                    string s = Server.MapPath("Images\\"+ lbl.Text + ".jpg");

                    FileInfo file = new FileInfo(s);

                    if (chk2 != null)
                    {
                        if (chk2.Text != "")
                        {

                            if (file.Exists)
                            {
                                chk2.NavigateUrl = "Images" + "/" + lbl.Text + ".jpg";
                                chk2.Text = "I";
                                // chk2.Text = ds.Tables[0].Rows[i][0].ToString();
                            }

                            else
                            {
                                chk2.Text = "";
                            }
                        }
                    }

                }

                #endregion

im using this code to show an image link if the image is available for that item..

hope that helps..

Thanks love_dude,

I have used following code to solve this:

string ErrorScreen = e.Row.Cells[8].Text;
            HyperLink hlink = new HyperLink();
            if (ErrorScreen != "")
            {
                hlink.ID = ErrorScreen;
                hlink.NavigateUrl = "http:\\NET\\ErrorImages\\" + ErrorScreen;
                hlink.Text = ErrorScreen.ToString();
                e.Row.Cells[8].Controls.Add(hlink);
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.