1

I have a Gridview that auto generates columns... The problem is, the data type are all imageurl.

when the gridview populates, the url is in label format.

I could define them as templatefield which works, but the requirement is to auto generate.

I read on MSDN of this, but i dont know how to proceed from there

private void BUChecker_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
}

2 Answers 2

0

You can alter this on its TemplateFields. See GridView controls'. see this for your reference.

1
0

I think you use RowDataBound as follows In case you don't want to use template field

protected void RowDataBound(Object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        //find your cell suppose it is Cell 0
       string imgUrl=e.Row.Cells[0].Text;
       Image img = new Imge();
       img.ImageUrl =imgUrl;
       e.Row.Cells[0].Controls.Add(img);

    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.