468,272 Members | 1,980 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

Row / Column gets much bigger when editing a row in grid

Hi there,
What determines the sizes of rows / columns / cells when a grid is in edit
mode ?

When I click the edit command of a row item, the whole grid 'bounces' to a
much larger size... and after update it reduces back again.

I have a custom crafted grid (AutoGenerateColumns = False) ... and can have
not placed any setting that would seem to cause this behaviour.

Is this a default type bahaviour ? How should I work around this such that
disconcerting size changes do not occur ?

thanks,

Bazza
Nov 19 '05 #1
4 1083
"Bazza Formez" <ba**********@paradise.net.nz> wrote in message
news:lM********************@news02.tsnz.net...
Hi there,
What determines the sizes of rows / columns / cells when a grid is in edit
mode ?

When I click the edit command of a row item, the whole grid 'bounces' to a
much larger size... and after update it reduces back again.

I have a custom crafted grid (AutoGenerateColumns = False) ... and can
have not placed any setting that would seem to cause this behaviour.

Is this a default type bahaviour ? How should I work around this such that
disconcerting size changes do not occur ?


Remember that it's all just HTML.

To find the answer, create a simple reproducer. Then, look at the HTML via
View Source befoire you put it into edit mode, and then look again
afterwards.

One thing I've seen cause these problems is BoundColumn columns. In edit
mode, these generate <input type="text"> fields, but without any size
attribute. That causes the column width to change. I replaced them with a
template column (with a size attribute) and the problem was gone.

John Saunders
Nov 19 '05 #2
Thanks John.. I will try that.
Regards,
Bazza

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:ez**************@tk2msftngp13.phx.gbl...
"Bazza Formez" <ba**********@paradise.net.nz> wrote in message
news:lM********************@news02.tsnz.net...
Hi there,
What determines the sizes of rows / columns / cells when a grid is in
edit mode ?

When I click the edit command of a row item, the whole grid 'bounces' to
a much larger size... and after update it reduces back again.

I have a custom crafted grid (AutoGenerateColumns = False) ... and can
have not placed any setting that would seem to cause this behaviour.

Is this a default type bahaviour ? How should I work around this such
that disconcerting size changes do not occur ?


Remember that it's all just HTML.

To find the answer, create a simple reproducer. Then, look at the HTML via
View Source befoire you put it into edit mode, and then look again
afterwards.

One thing I've seen cause these problems is BoundColumn columns. In edit
mode, these generate <input type="text"> fields, but without any size
attribute. That causes the column width to change. I replaced them with a
template column (with a size attribute) and the problem was gone.

John Saunders

Nov 19 '05 #3
On Thu, 09 Dec 2004 13:12:40 +1300, Bazza Formez wrote:
Hi there,
What determines the sizes of rows / columns / cells when a grid is in edit
mode ?

When I click the edit command of a row item, the whole grid 'bounces' to a
much larger size... and after update it reduces back again.

I have a custom crafted grid (AutoGenerateColumns = False) ... and can
have not placed any setting that would seem to cause this behaviour.

Is this a default type bahaviour ? How should I work around this such that
disconcerting size changes do not occur ?


When a datagrid is in item view the widths of the columns are
automatically set to the widest necessary for the data, when in edit mode
the width of the textboxes decides the width of the columns. You could fix
the width of the columns with the itemstyle property so that the columns
are as wide as the edit textboxes when in item view.

Tony

Nov 19 '05 #4
I think this is the default behavior. I solved this problem writing the
following code in the EditCommand event, which you can adapt to your
purposes:

private void grdPolicy_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e) {

this.lblMessage.Text = "";

this.saveSelection();

this.grdPolicy.EditItemIndex = (int) e.Item.ItemIndex;
this.gridBind();
this.grdPolicy.Columns[(int) NumColumns.select].Visible = false;

// cambiare le dimensioni del text grid per l'editazione

System.Web.UI.WebControls.TextBox txt;
txt = (TextBox) this.grdPolicy.Items[(int) e.Item.ItemIndex].Cells[(int)
NumColumns.issuing].Controls[0];
txt.Columns = 10;
txt = (TextBox) this.grdPolicy.Items[(int) e.Item.ItemIndex].Cells[(int)
NumColumns.expiry].Controls[0];
txt.Columns = 10;
txt = (TextBox) this.grdPolicy.Items[(int) e.Item.ItemIndex].Cells[(int)
NumColumns.premium].Controls[0];
txt.Columns = 10;
if (decimal.Parse(txt.Text) == 0) {
txt.Text = "";
}
}
As you can realize, you can change the Columns property of the text boxes
for the columns which aren't read only. I hope this can help you.
--
Vanni Tomezzoli
S. Donato Mil., Milano, Italy
http://xoomer.virgilio.it/vtomezzo

"Bazza Formez" <ba**********@paradise.net.nz> ha scritto nel messaggio
news:lM********************@news02.tsnz.net...
Hi there,
What determines the sizes of rows / columns / cells when a grid is in edit
mode ?

When I click the edit command of a row item, the whole grid 'bounces' to a
much larger size... and after update it reduces back again.

I have a custom crafted grid (AutoGenerateColumns = False) ... and can have not placed any setting that would seem to cause this behaviour.

Is this a default type bahaviour ? How should I work around this such that
disconcerting size changes do not occur ?

thanks,

Bazza

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Gord | last post: by
2 posts views Thread by Will | last post: by
3 posts views Thread by TT (Tom Tempelaere) | last post: by
2 posts views Thread by Raj | last post: by
4 posts views Thread by Mike | last post: by
4 posts views Thread by Aaron Smith | last post: by
2 posts views Thread by schaapiee | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.