3

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);
}
4

1 回答 1

1

最近我遇到了这个问题,所以这里有一个链接,可能对未来的访问者有所帮助 Create DetailsView from codebehind

于 2013-08-18T04:04:45.817 回答