controlling size of editcommand column in edit mode

N

Nedu N

I am facing problem in controlling the size of the edit command coulmn
after...both before clicking edit and also during when we see the
update/cancel look...i have got imgaes instead of Edit and Update/Cancel
text...
Also i face problems in controlling the column widths in edit mode on my
template columns....Item-Style width doesn't seem to work....
 
A

Alvin Bruney

this is easier accomplished with javascript. try adding a width attribute
with a dimension to the cell
cell.attribute("width","10");
roughly
 
L

Lewis Wang [MSFT]

Hi Nedu,

I agree with the answer from Alvin. I'd like to add more information.

Before clicking edit, you may control the column width in the
DataGrid.ItemCreated. The following is a code snippet for demonstration.

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item ||e.Item.ItemType==
ListItemType.AlternatingItem)
{
e.Item.Cells[0].Attributes .Add("width","100");
}
}

After clicking edit, you may control the column width of controls in the
DataGrid using DataGrid.PreRender event. Please check a code snippet below
for a demonstration. You may modify the code to meet your requirements.

private void DataGrid1_PreRender(object sender, System.EventArgs e)
{
int n=DataGrid1.EditItemIndex;
if (n!=-1)
{
TextBox t1=(TextBox)DataGrid1.Items [n].Cells [1].Controls[0];
t1.Width =150;
}
}

Does this answer your question? Please let me know if you need more
information

Best regards,
Lewis

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Reply-To: "Nedu N" <[email protected]>
| From: "Nedu N" <[email protected]>
| Subject: controlling size of editcommand column in edit mode
| Date: Fri, 15 Aug 2003 09:46:47 -0700
| Lines: 8
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: machine45.qwest.net 204.154.239.45
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:6177
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| I am facing problem in controlling the size of the edit command coulmn
| after...both before clicking edit and also during when we see the
| update/cancel look...i have got imgaes instead of Edit and Update/Cancel
| text...
| Also i face problems in controlling the column widths in edit mode on my
| template columns....Item-Style width doesn't seem to work....
|
|
|
 
V

vMike

You might also try something like this (snip)

Sub Display2_ItemDataBound(sender As Object, e As DataGridItemEventArgs)

if display2.EditItemIndex > -1 then
if display2.EditItemIndex = e.item.itemindex then
ctype(e.Item.Cells(3).controls(0),textbox).Width = Unit.Pixel(35)
ctype(e.Item.Cells(6).controls(0),textbox).Width = Unit.Pixel(45)

....
 

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,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top