Click here to Skip to main content
15,910,411 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,

I add a gridview dynamically and to this gridview I also add command field dynamically at server side. Please refer following code. On the selecttext property of the commandfield I actually add an image.

VB
oAspCommandField = New CommandField()
           oAspCommandField.ShowSelectButton = True
           oAspCommandField.ButtonType = ButtonType.Link
           oAspCommandField.SelectText = "<img align=top BorderColor=transparent border=0 alt='Show in Map' src='images/map20_norm.gif' />"
           oGridView.Columns.Add(oAspCommandField)


But now I want to have this image centered in the gridview column.

What changes do I need in the above code?

Thanks.

Vijay
Posted

Solved as by wrapping the image in div and style with width = 100% text align = center and cursor as hand.
 
Share this answer
 
C#
oAspCommandField.ItemStyle-HorizontalAlign = "Center"


If this helped you then marked it as answer and Please Vote.
 
Share this answer
 
Comments
NMehta83 9-Oct-10 1:33am    
Please comment for the downvote so i can understand for the next time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900