EditForm findcontrol

2 posts, 0 answers
  1. lakmal
    lakmal avatar
    76 posts
    Member since:
    Jun 2009

    Posted 27 Dec 2009 Link to this post

    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
  2. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 27 Dec 2009 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top