This is a migrated thread and some comments may be shown as answers.

Field Widths on auto generated edit

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 10 Jul 2011, 05:12 PM
--- Disregard..  I found that the code pasted here does work, but I was setting the event in the page_init
RadGrid2.ItemCreated += new GridItemEventHandler(RadGrid2_ItemCreated);
which for some reason doesn't work.  Setting it on the aspx side:
OnItemCreated="RadGrid2_ItemCreated">
works..

Anyone know why defining the event in the code behind wouldn't work?

---

Hi,

Is there any way to change the widths of the textboxes that are created when you allow the grid to auto generate the edit template, without having to build a custom template?

Currently they all come out the same size, and half are too long and the other half are too short...

I tried code from a post with the same question, but it doesn't seem to do anything...

protected void RadGrid2_ItemCreated(object sender, GridItemEventArgs e)
        {
            if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
            {
                GridEditableItem edititem = (GridEditableItem)e.Item;
                TextBox txtbx = (TextBox)edititem["Donor_ID"].Controls[0];
                txtbx.Width = Unit.Pixel(50);
            }
  
        }


Thanks,

Matt

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 14 Jul 2011, 09:44 AM
Hi Matt,

I tested here locally and when I use:
protected void Page_Init(object sender, EventArgs e)
{
    RadGrid1.ItemCreated += new GridItemEventHandler(RadGrid1_ItemCreated);
}
 
void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
 
}
RadGrid1_ItemCreated, gets executed for my grid.

Could you place a break point inside Page_Init function,  and see if the handler is attaching?

Kind regards,
Vasil
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or