Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the width of the Edit Button col in a GridView?

I have a gridview that sets the AutoGenerateEditButton="true"

How can I set the width of the resulting column?

like image 992
chris Avatar asked Jan 25 '26 07:01

chris


2 Answers

I don't know if you can set the width when the Edit button is auto-generated.
But you can set it if you add the CommandField.

Steps:

  1. Set AutoGenerateEditButton back to false
  2. Expand the GridView Tasks window using the funny little arrow button in the top right of the GridView
  3. Select 'Edit Columns'
  4. Expand the 'Command Field' node in the Available Fields list.
  5. Select 'Edit, Update, Cancel' and then click the Add button
  6. Make sure 'Edit, Update, Cancel' is selected in the Selected Fields list
  7. Expand the 'ItemStyle' node in the CommandField properties list
  8. Shazaam, there is your width property down near the bottom.

The Command buttons (edit, cancel, update) will still behave as if you had auto-generated them, you just get more control over the layout.

Gridview CommandField

like image 106
Dhaust Avatar answered Jan 26 '26 22:01

Dhaust


I believe that you don't have direct control over the column containing the edit button - because of the "AutoGenerate" in the property you are setting, it is rendered automatically.

An alternative is to set AutoGenerateEditButton="False", and define a column containing the Edit command button yourself. Then in the markup, you can set the width of that column yourself.

like image 30
Ken Ray Avatar answered Jan 26 '26 21:01

Ken Ray