Question

I have a grid view that, on selected index, will populate a details view. If the selected index happens to have multiple IP Address's I want to add additional fields to display them. They don't need to be databound since I know the data. I'm using the code below to create the additional template fields. This is done in the Data Binding event.

This works until I select a different row in the grid view, then no data is displayed in the details view. My theory is that it's trying to bind the data but there are a different amount of values returned from the database than controls to put them in. I guess is there an easier way to do this?

// Check for multiple IP
countIP = devicesDetails_CountIP(devicesDataKey);

if (countIP > 1)
{
  TemplateField IPAddress2 = new TemplateField();
  devicesDetailsView.Fields.Insert(0, IPAddress2);
}
Was it helpful?

Solution

Recently I came across this question, so here is a link that may be of help for future visitors Create DetailsView from codebehind

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top