Search code examples
asp.nettelerikradgridradtextbox

How do I set a default value of 0 to a radtextbox in a radgrid if the value is null after databind?


i have a series of radtextboxes as columns in a radgrid. The data they pull is often null. I'd like them to have a default value of zero in those cases. How do i accomplish this?

I tried this without success:

    protected void rGrid_Inductions_PreRender(object sender, EventArgs e)
    {
        foreach (GridDataItem item in rGrid_Inductions.Items)
        {
            foreach (Control ctr in item.Controls)
            {
                if (ctr.GetType() == typeof(RadTextBox))
                {
                    (ctr as RadTextBox).Text = "0" + (ctr as RadTextBox).Text;
                }
            }                
        }  

        rGrid_Inductions.Rebind();
    }

Appreciate the help


Solution

  • why dont u just set the Default Text of RadTextBox=0 when you creating them and then in this (prerender loop) modify them if they are not null;