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

access text box in the edit form

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
beeta one
Top achievements
Rank 1
beeta one asked on 27 Nov 2012, 06:54 AM
Hi, i hav a teXt box in the editform. If the entered text is '12' i want to show a msg in a label. How can i do this?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Nov 2012, 07:07 AM
Hi,

Please try the following code snippet to show a message in the label when the Textbox value is '12'.I guess both the Label and the TextBox are in EditItemTemplate of GridTemplateColumn.

C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem edit = (GridEditableItem)e.Item;
        TextBox txt = (TextBox)edit.FindControl("TextBox1");
        txt.AutoPostBack = true;
        txt.TextChanged += new EventHandler(txt_TextChanged);
    }
}
void txt_TextChanged(object sender, EventArgs e)
{
    TextBox txt = (TextBox)sender;
    GridEditableItem edit=(GridEditableItem)txt.NamingContainer;
    if (txt.Text == "12")
    {
        Label lbl = (Label)edit.FindControl("Label1");
        lbl.Text = "your text";
    }
}

Thanks,
Shinu.
Tags
Grid
Asked by
beeta one
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or