EditForm findcontrol

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

    Posted 27 Dec 2009 Link to this post


    My find control is always return  null value.

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


    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();
                    string sqlStr = "CreateTicket";
                    SqlCommand cmd = new SqlCommand(sqlStr, Conn);

    How can i use findcontrol?

  2. Steve
    Steve avatar
    1871 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 


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

Back to Top