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

Get value from insert form textbox

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aleš
Top achievements
Rank 1
Aleš asked on 27 Aug 2008, 07:11 PM
Hello,

I have some troubles with radgrid insert from. When i click on add new, my popup shows. On this form I want to check some values in one textbox. So I added a linkbutton to execute my method.

Problem is that i can set textbox to some value, but can't read from it.
PROBLEM ( stPoste = posta.Text;)

Any help ?

Thanks in advance.
Strela

    public void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.InitInsertCommandName) 
        { 
            e.Canceled = true
            e.Item.OwnerTableView.InsertItem(); 
 
            GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem(); 
            TextBox drzava = insertedItem.FindControl("TextBox_drzava") as TextBox; 
            drzava.Text = "Slovenija"
            TextBox id_sod = insertedItem.FindControl("TextBox_idsod") as TextBox; 
            id_sod.Text = Profile.stevilkaSodelavca; 
        } 
        if (e.CommandName == "Add") 
        { 
            e.Canceled = true
            e.Item.OwnerTableView.InsertItem(); 
 
            //PODATKI IZ BAZE 
            String strKraj = ""
            String stPoste = "0"
 
            GridEditableItem insertedItem = RadGrid1.MasterTableView.GetInsertItem(); 
             
            TextBox posta = insertedItem.FindControl("TextBox_posta") as TextBox; 
            stPoste = posta.Text;  //HERE I GOT "" (empty string) 
 
            TextBox drzava = insertedItem.FindControl("TextBox_drzava") as TextBox; 
            drzava.Text = "Slovenija"
            TextBox id_sod = insertedItem.FindControl("TextBox_idsod") as TextBox; 
            id_sod.Text = Profile.stevilkaSodelavca; 
            TextBox kraj = insertedItem.FindControl("TextBox_kraj") as TextBox; 
            kraj.Text = strKraj
 
        } 
 
    }     

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 28 Aug 2008, 07:57 AM
Hi,

I have tried the following code snippet to access text from Popup Insert form. Give a try with the below code and see if it is working.

CS:
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "PerformInsert") 
        { 
            GridEditFormInsertItem insertitem = (GridEditFormInsertItem)e.Item.OwnerTableView.GetInsertItem(); 
            TextBox txtbx = (TextBox)insertitem["columnUniqueName"].Controls[0]; 
            string strtxt = txtbx.Text; 
        } 
 
    } 

Thanks
Shinu.
0
Shinu
Top achievements
Rank 2
answered on 28 Aug 2008, 08:01 AM
 
Tags
Grid
Asked by
Aleš
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or