Editing in GridViews (formatting!)

A

AmitKu

I've got the Gridview going at full speed, and I've enabled editing,
but when I click on the "edit" button, this ugly editing UI comes up.
Well it's not ugly, but it's not great either.

How do I change the font/font size of the text thats being edited?

Thanks in advance,
Amit
 
D

David R. Longnecker

Hello Amit,

Option #1 - Use the IDE Tools to Modify the EditItemTemplates

The easiest way is to edit the template for your GridView Control.

1. First off, convert your bound columns to template columns.

Edit Columns > select your field > 'Convert this field into a TemplateField'.

2. Then, on the context [>] menu, click Edit Templates and select the EditItemTemplate
of the column you wish to modify.

From here, you can modify the control (replace text boxes with drop downs,
etc) and the font/formatting of the edit boxes.

Option #2 - Hand coding. :D

You can also hand-type the entries that are generated by the IDE in #1.
They look like below. Notice that I expanded the text box to a fixed size
and applied font formating (the EditItemTemplate), but left the ItemTemplate
alone so the "grid look" remains.

<asp:TemplateField HeaderText="subject_text" SortExpression="subject_text">

<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Font-Bold="True" Font-Names="Bell
MT" Height="47px"
Rows="5" Text='<%# Bind("subject_text") %>' Width="244px"></asp:TextBox>
</EditItemTemplate>

<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("subject_text")
%>'></asp:Label>
</ItemTemplate>

</asp:TemplateField>

Option #3 - Overall formatting on the GridView

In the <asp:GridView> tag, you can add an <EditRowStyle> tag that applies
formatting and/or CSS to the general "edit row".

Hope this helps!

-David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top