General information
Category:
The Mere Mortals .NET Framework
>Steve,
>
>>I've noticed that the mmDataGrid doesn't handle the column collection properly when you have the AutoGenerateColumns set on. Every time I've tried this, I get an Index Out of Range exception. I've also tried adding bound columns to the mmDataGrid at run time and can't seem to get the binding to work properly.
>
>I haven't seen this problem before with the AutoGenerateColumns property. If you drag and drop an mmDataGrid on a form this property is automatically set to true. I'd be curious to see if you drop a new mmDataGrid on your Web Form and simply set the BindingSource type if you still see this error.
>
>Regarding bound columns you have added dynamically at run time, do other design-time columns bind properly? If none of the columns are binding, try calling the MM .NET Web form's BindControl() method.
>
>Regards,
Calling the BindControl() method fixed the problem with the columns added via code.
I left out some important information on the AutoGenerateColumns issue. The error happens when I call the SaveDataSet in the code below.
private void dgStates_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// Get the item to be updated
this.dgStates.EditItemIndex = e.Item.ItemIndex;
// Retrieve the previous States DataSet
DataSet dsStates = (DataSet)Session["dsStates"];
// Save the DataSet (the DataGrid automatically binds back)
this.oStates.SaveDataSet(dsStates);
// Reset the edited item and rebind the DataGrid
this.dgStates.EditItemIndex = -1;
this.BindControl(this.dgStates);
}
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only