G
Guest
I have a web app that I have been working on for the last couple of weeks
trying to solve this problem. One page contains a GridView with four base
columns, and an unknown number of columns to be added depending on the data
source chosen. I create some TemplateColumns based on the data returned for
the selection, and add them into the GridView using the following code:
DataSet dsTraits =
ssql_common.selectRubricTraits(sConnectionString,
Convert.ToInt32(measInstID));
DataTable dt = dsTraits.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
TemplateField field = new TemplateField();
field.HeaderStyle.HorizontalAlign =
HorizontalAlign.Center;
field.HeaderTemplate = new
DataGridTemplate(ListItemType.Header, (string)dt.Rows["trait_name"],
(int)dt.Rows["trait_id"], scoreCategoryList);
field.ItemStyle.HorizontalAlign =
HorizontalAlign.Center;
field.ItemTemplate = new
DataGridTemplate(ListItemType.Item, (string)dt.Rows["trait_name"],
(int)dt.Rows["trait_id"], scoreCategoryList);
gvMultiEval.Columns.Add(field);
}
gvMultiEval.DataBind();
This will load the page correctly, but on a postback, the contents of the
dynamically generated columns is destroyed, and so is inaccessible. The
columns are still there, but there is no content within the cells. Is there
any way I can get this data to persist somewhere long enough to record the
changes within the GridView so I can save it somewhere? I could then recreate
the GridView and repopulate it, but by the time any event is fired, I have no
access to the data.
Thanks in advance, and please ask questions if you don't understand me. I'd
be glad to give more code if you need it, as well.
trying to solve this problem. One page contains a GridView with four base
columns, and an unknown number of columns to be added depending on the data
source chosen. I create some TemplateColumns based on the data returned for
the selection, and add them into the GridView using the following code:
DataSet dsTraits =
ssql_common.selectRubricTraits(sConnectionString,
Convert.ToInt32(measInstID));
DataTable dt = dsTraits.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
TemplateField field = new TemplateField();
field.HeaderStyle.HorizontalAlign =
HorizontalAlign.Center;
field.HeaderTemplate = new
DataGridTemplate(ListItemType.Header, (string)dt.Rows["trait_name"],
(int)dt.Rows["trait_id"], scoreCategoryList);
field.ItemStyle.HorizontalAlign =
HorizontalAlign.Center;
field.ItemTemplate = new
DataGridTemplate(ListItemType.Item, (string)dt.Rows["trait_name"],
(int)dt.Rows["trait_id"], scoreCategoryList);
gvMultiEval.Columns.Add(field);
}
gvMultiEval.DataBind();
This will load the page correctly, but on a postback, the contents of the
dynamically generated columns is destroyed, and so is inaccessible. The
columns are still there, but there is no content within the cells. Is there
any way I can get this data to persist somewhere long enough to record the
changes within the GridView so I can save it somewhere? I could then recreate
the GridView and repopulate it, but by the time any event is fired, I have no
access to the data.
Thanks in advance, and please ask questions if you don't understand me. I'd
be glad to give more code if you need it, as well.