0

In gridview we have 4 columns

Asset Type , Asset Name , Asset Description , Icon

Now We want to add image in Icon column,but will be different depending upon the type of the document. Eg. If asset type is doc then we will display Doc icon;if asset type is jpg then we will display Jpg icon

How to bind different images in each row depending upon the asset type...

Need Help !!!

Thanks

1 Answer 1

1

I would look into the GridView RowDataBound method. Access the row DataItem, check for the type, and then either dynamically update the ImageUrl of the icon (presuming that your icon is an <asp:Image>

Some Reading:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

Conditional output in cell based on row data in Gridview's RowDataBound event

Another way would be to create a public function which you could pass in the asset type, and return the URL of the image.

<asp:Image ImageUrl='<%#GetImageUrl("imageType")%>'

public string GetImageUrl(string imageType){ 
    //return url 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.