Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Steve via DotNetMonster.com #1
Postbacks removing DataGrid which has BoundColumns created in code.
I'm having an issue with my DataGrid being removed from the page on postbacks.
All of the columns are added programatically as the application requires user
selection to decide what columns of data to present. When a column is
selected for sorting from this grid, or when another control which
AutoPostBacks is used, the DataGrid is wiped away. How can I avoid this
when the columns are created dynamically? I'm not concerned with the
controls removing it, as this actually is convenient. The sorting is the
main issue, though I assume the problem is all tied together.
// A bit of code from bindGrid(string sortfield)
if (chkWM.Checked)
{
BoundColumn wm = new BoundColumn();
wm.HeaderText="WM";
wm.DataField="WM";
wm.SortExpression="WM";
wm.DataFormatString="{0:00}";
wm.HeaderStyle.ForeColor=Color.White;
wm.HeaderStyle.BackColor=Color.Black;
summaryGrid.Columns.Add(wm);
summaryString += " AND WM="+ddlWM.SelectedValue;
groupString += ", WM";
}
DataView Source = dataGridTable.DefaultView;
Source.Sort = sortfield;
summaryGrid.DataSource = Source;
summaryGrid.DataBind();
}//end bindGrid()
public void summaryGrid_Sort(object sender, DataGridSortCommandEventArgs e)
{
bindGrid(e.SortExpression);
DataView Source = dataGridTable.DefaultView;
Source.Sort = e.SortExpression;
if (asc.Checked)
Source.Sort = e.SortExpression + " ASC";
else
Source.Sort = e.SortExpression + " DESC";
summaryGrid.DataSource = Source;
summaryGrid.DataBind();
}//end summaryGrid_Sort()
Thanks - Steve
Steve via DotNetMonster.com Guest
-
Editable datagrid postbacks one event behind in display
I have a very simple datagrid with an editable button. The problem is if you click the edit button initially nothing happens. If you click a... -
Adding rows to DataGrid across multiple PostBacks
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest... -
Validating Boundcolumns in datagrid
Hi, I have a Datagrid with boundcolumns. I need to validate the textbox when the user clicks the update link.How can i do it. Also i need to set... -
Removing the 'created with director' message
Hello, i have created a piece of work in director, and published it as an exe. Whenever the user presses EXIT or gets out of the program, a message... -
DataGrid - Unable to update with dynamic BoundColumns
Hi everybody, A very strange problem with WebControls : A Datagrid in an ASp.net application; Bound with a dataset through ado.net; The...



Reply With Quote

