Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
FindControl in RowEditingTemplate
posted

I have a WebDialogWindow embedded in a WebDataGrid RowEditingTemplate that is displayed when a row on the grid is put into edit mode.  The window displays a toolbar, field labels, input fields, OK and Cancel buttons, and field help panels for each field by default are hidden.

When the user clicks on the Help button on the toolbar then the field help panels are displayed and when they click the Help button again the field help panels are hidden (toggled).

My WebDialogWindow was working great until I put it in the RowEditingTemplate.

When the toolbar Help button is clicked the code behind is executed and can't FIND the asp:panels (or any RowEditingTemplate controls for that matter) in order to display/hide them.

I'm using the code behind because I found no way to automatically resize and position the WebDialogWindow on the client side so doing anything on the client side to display/hide the asp:panels is not going to help.

So my question is:  How do you get references to the RowEditingTemplate controls from the code behind when the grid is editing a row?

bmoneilus

 

Parents
No Data
Reply
  • 444
    Suggested Answer
    posted

    I had a similiar issue where I was unable to find a control in the edit Item template. Infragistics never helped me with it and I ended up writing my own solution. This is how I did it.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Protected Overrides Function GetEditTemplateControlIds() As IDictionary(Of String, String)

     

     

    Dim retVal As New Dictionary(Of String, String)

     

     

    Dim ctls As ControlCollection = WebDataGrid1.Controls(0).Controls(0).Controls

    retVal.Add(

    "buttonOKId", (From item As Control In ctls _

     

     

    Where item.ID = "buttonOK" _

     

     

    Select item).Single().ClientID)

    retVal.Add(

    "buttonCancelId", (From item As Control In ctls _

     

     

    Where item.ID = "buttonCancel" _

     

     

    Select item).Single().ClientID)

    retVal.Add(

    "txtDescriptionId", (From item As Control In ctls _

    Where item.ID = "txtDescription" _

     

     

    Select item).Single().ClientID)

     

     

    Return

    retVal

     

     

    End

    Function

    This gets you a mapping of the client IDs. You can then somehow loop through the collection and and write them out to the page so you can use them. I just write it to a JSON object on the page and consume it client side.

    var privateLabelControls = {
    	"webDataGridId": "ctl00_ContentPlaceHolder1_WebDataGrid1",
    	"buttonOKId": "ctl00_ContentPlaceHolder1_WebDataGrid1_ctl00_buttonOK",
    	"buttonCancelId": "ctl00_ContentPlaceHolder1_WebDataGrid1_ctl00_buttonCancel",
    	"txtDescriptionId": "ctl00_ContentPlaceHolder1_WebDataGrid1_ctl00_txtDescription"
    };
    
    
    basically as you see "_ctl00" is just added to the webdatagridId and then the control names you provided is appended as well.
    
    
    Hope this gives you some ideas.
    Cheers,
    ~ck 
    

     

Children
No Data