H
Harlan.Vossos
I am using the GridView component to display data as an HTML table. I
create a dataset and manually bind the dataset to the grid as shown
below. One of the columns is displayed as a checkbox. I have button
outside the grid. When the button is clicked I want to iterate thru
the rows in the grid and update the database. The problem is when i
iterate the rows in the click event there are NO rows in the grid. The
DataGrid in version 1.1 would rebuild the grid from viewstate on
postbacks. Does the GridView do the same? or do you have to do
something special? I am aware of the sql data source and binding the
grid to it with no code, but i do not want to do this.
Protected void Page_Load(object sender, EventArgs e) {
if ( ! IsPostBack){
DataSet Data = GetDataset();
MyGridView.DataSource = Data
MyGridView.DataBind();
}
}
protected void DoClick(object sender, EventArgs e){
// I Get No Rows??? Why didn't the grids get re-binding from
viewstate????
foreach(GridViewRow Row in MyGridView.Rows) {
NotificationIds[Row.DataItemIndex] =
Convert.ToInt32 (MyGridView.DataKeys[Row.DataItemIndex].Value);
}
}
create a dataset and manually bind the dataset to the grid as shown
below. One of the columns is displayed as a checkbox. I have button
outside the grid. When the button is clicked I want to iterate thru
the rows in the grid and update the database. The problem is when i
iterate the rows in the click event there are NO rows in the grid. The
DataGrid in version 1.1 would rebuild the grid from viewstate on
postbacks. Does the GridView do the same? or do you have to do
something special? I am aware of the sql data source and binding the
grid to it with no code, but i do not want to do this.
Protected void Page_Load(object sender, EventArgs e) {
if ( ! IsPostBack){
DataSet Data = GetDataset();
MyGridView.DataSource = Data
MyGridView.DataBind();
}
}
protected void DoClick(object sender, EventArgs e){
// I Get No Rows??? Why didn't the grids get re-binding from
viewstate????
foreach(GridViewRow Row in MyGridView.Rows) {
NotificationIds[Row.DataItemIndex] =
Convert.ToInt32 (MyGridView.DataKeys[Row.DataItemIndex].Value);
}
}