DataGrid Edit TextBox

A

Aidal

Hi NG.

I'm having trouble controling the size of the textboxes that appear when the
user clicks the "edit" button for a row in my datagrid.
I know it can be done and I know it doesn't require much, but I just can't
seem to find out how to anyway.

If anyone could help me out with this little problem it would be much
appreciated :)

Thanks
/Aidal
 
A

alvinz_c

Hi, Aidal, you have two ways to do it. If you are using the BoundColumn, then
you can set the width of textbox in the ItemCreated event.

protected void dgrd_ItemCreated(Object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
TextBox txt = (TextBox)e.Item.Cells[X].Controls[0];
txt.Width = < the width you want it to be>;
}
}

Another way is set the TextBox's width declaractively in the TemplateColumn.


Hope this helps....
 

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

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top