0

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

4

2 に答える 2

1

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;

于 2013-05-20T19:46:54.693 に答える
1

デザイン ビューまたはコード ビハインドhttp://www.telerik.com/help/aspnet-ajax/input-textbox-basicsでコントロールを作成している場合は、ページにコントロールをドロップするときに既定値を確実に設定できます。 html

なぜテキストを

(ctr as RadTextBox).Text = "0" + (ctr as RadTextBox).Text;

テキストに関係なく、0は永続的であるはずですか? テキストのサンプルを見せてもらえますか?

ただし、デフォルトとして 0 が必要な場合は、設計時に値を割り当てるか、上記のドキュメントのようにコード ビハインドを行うだけです。

于 2013-05-21T00:00:44.573 に答える