chris
chris

Reputation: 37460

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?

Upvotes: 3

Views: 6419

Answers (3)

Mmm
Mmm

Reputation: 951

12+ years later, we can do this with CSS:

td:first-child
{
    width: 5%;
}

Upvotes: 0

Ken Ray
Ken Ray

Reputation: 2528

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.

Upvotes: 2

Dhaust
Dhaust

Reputation: 5550

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

Upvotes: 7

Related Questions