I am upgrading from the ultra web grid and with the grid I am upgrading from we iterate through all controls within a column by first iterating through the columns to get each column (I have managed to port this to the WebDataGrid just fine) and then inside of that iteration iterate through the controls. For the UltraWebGrid it was done like so:
For Each c As Control In DirectCast(ugc, Infragistics.WebUI.UltraWebGrid.TemplatedColumn).CellItems(e.Row.Index).Controls 'Action to performNext
I cannot find a control collection within the column for the WebDataGrid for me to perform a similar function. If it helps I am only handling TemplateDataFields and looking for controls within their ItemTemplate. this is being done in the InitilizeRow event for the WebDataGrid. I have tried a accessing the items in the record for said column by doing:
For Each c As Control In e.Row.Items.Record.Items(column.Index).Record.Items 'Action to performNext
Yet this returns nothing and thus causes errors. How can one iterate through the controls in an TemplateDataField's ItemTemplate
Thank you for the reply, the idea has been submitted as requested
Hello Guy Curtis,
We ask our customers to submit their product ideas themselves. This way, you can provide as much detail as you like for your idea, and it allows our product management team to be in direct contact with you to follow up with you.
Please follow the steps I provided in my last update to submit the product idea yourself.
If you need any further assistance with this, please let me know.
Thank you for the reply, I am aware of the find by key method and use it quite frequently, this happens to be an instance where I am trying to optimize the code and also frankly was looking for an alternative to listing all 20 controls which required the same logic to be applied to them.
You stated that this has been determined to be a new product idea prior to listing out how I would add new product ideas, do you require me to submit this as a new product idea or has that process already been done and the additional information is merely that?
Thank you for posting in our forums!
If you know the IDs of the controls in the template, you can access the controls with the FindControl method. You can see an example of this code here:
Protected Sub WebDataGrid1_InitializeRow(sender As Object, e As RowEventArgs) Handles WebDataGrid1.InitializeRow Dim lbl As Label = e.Row.Items.FindItemByKey("TemplateField_0").FindControl("Label1") lbl.Text = "Test" End Sub
If you must iterate through the template, this is a little trickier and would be considered a new product idea. There is a workaround using Reflection that you can use to get the TemplateContainer object and iterate over the Controls collection. You can do this with the following example code:
Protected Sub WebDataGrid1_InitializeRow(sender As Object, e As RowEventArgs) Handles WebDataGrid1.InitializeRow Dim row As ControlDataItem = e.Row.Items.FindItemByKey("TemplateField_0") Dim myType As Type = row.GetType() Dim myProp As PropertyInfo = myType.GetProperty("TemplateContainer", BindingFlags.NonPublic Or BindingFlags.Instance) Dim templateContainer As Infragistics.Web.UI.TemplateContainer = myProp.GetValue(row, Nothing) For Each c As Control In templateContainer.Controls 'Action to perform System.Diagnostics.Debug.WriteLine(c.ClientID) Next End Sub
After working on this workaround and doing some research, iterating over controls in a templatefield has been determined to be a new product idea. You can suggest new product ideas for future versions (or vote for existing ones) at <http://ideas.infragistics.com>.
There are many benefits to submitting a product idea:
- Direct communication with our product management team regarding your product idea.
- Notifications whenever new information regarding your idea becomes available.
- Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
- Allow you to shape the future of our products by requesting new controls and products altogether.
- You and other developers can discuss existing product ideas with members of our Product Management team.
Steps to create your idea:
1. Log into the Infragistics Product Idea site at http://ideas.infragistics.com (creating a new login if needed).
2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
3. Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
The Product Idea site puts you in the driver’s seat and allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Thank you for contacting Infragistics.
Could really do with a response to this question as it is holding up our ability to upgrade to the newer versions