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

EditForm findcontrol

1 Answer 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lakmal
Top achievements
Rank 2
lakmal asked on 27 Dec 2009, 04:28 PM
Hi,

My find control is always return  null value.

 </Columns>            
              <EditFormSettings EditFormType="Template">                  
              <EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton">                
                </EditColumn>                  
                    <FormTemplate>                    
                    <table id="Table2" cellspacing="2" cellpadding="1"  border="0" rules="none"
                            style="border-collapse: collapse; background: white;">
                        
                        <tr>
                             <td>
                                    <table >
                                         
                                                <tr>
                                                <td>
                                                 <b>MaxTickets</b>
                                                </td>                                                
                                                <td>
                                                
                                                         <asp:TextBox ID="txtMaxTickets" Text='<%# Bind("MaxTickets") %>' runat="server"></asp:TextBox>

                                                </td>
                                            </tr>
                                            
             

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
        
            if (e.CommandName == "cmdTicket")
            {
              
                GridDataItem item = (GridDataItem)e.Item;
                TextBox txtMaxTickets = (TextBox)item.FindControl("txtMaxTickets");  


                DbConnection Con = new DbConnection();
                SqlConnection Conn = new SqlConnection();
                Conn = Con.SQLConnection();
                Conn.Open();
                string sqlStr = "CreateTicket";
                SqlCommand cmd = new SqlCommand(sqlStr, Conn);
    

How can i use findcontrol?

lakmal

1 Answer, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 27 Dec 2009, 07:42 PM
Will this work for you?

if (e.Item is GridEditableItem) 
           { 
               GridEditableItem editedItem = e.Item as GridEditableItem; 
               //here editedItem.SavedOldValues will be the dictionary which holds the 
               //predefined values 
 
              //Prepare new dictionary object 
               Hashtable newValues = new Hashtable(); 
               e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); 
              //the newValues instance is the new collection of key -> value pairs 
              //with the updated ny the user data 
 
           } 

http://www.telerik.com/help/aspnet-ajax/grdretrieveoriginalvaluesforediteditem.html

I think FindControl works on the GridEditableItem as well...

Steve
Tags
Grid
Asked by
lakmal
Top achievements
Rank 2
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or