DataGrid probs

gailfuzzy

New Member
I'm having problems with the datagrid control... hopefully someone here can help.<BR>I'm using the EditCommandColumn with the OnEditCommand attribute to call dgrAdmin_Edit(sender as object, e as DataGridCommandEventArgs). My code looks like this:<BR><BR> Sub dgrAdmin_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)<BR> Response.Write("dgrAdmin_Edit")<BR> dgrAdmin.EditItemIndex = e.Item.ItemIndex<BR> PopulateAdminList()<BR> End Sub<BR><BR>The PopulateAdminList sub is what actually populates the datagrid. Here is the code for it:<BR><BR> Dim sProc As String<BR> Dim ds As DataSet<BR><BR> sProc = "sp_GetBooks"<BR> lblAdminType.Text = "Books"<BR> Dim oCommand As New SqlDataAdapter(sProc, New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")))<BR> oCommand.SelectCommand.CommandType = CommandType.StoredProcedure<BR> ds = New DataSet()<BR> oCommand.Fill(ds, "Books")<BR> dgrAdmin.DataSource = ds.Tables("Books").DefaultView<BR> dgrAdmin.DataBind()<BR><BR>Also, in my Page_Load I have:<BR><BR>If Not Page.IsPostBack Then<BR> PopulateAdminList()<BR>End If<BR><BR>Everything looks as if it should work, however, when I click on any of the EditButton Columns, the page reloads but the grid does not bind, that is, the dgrAdmin_Edit sub does not get called. Can anyone help me?<BR><BR>Thanks,<BR>Joe FioriniI think I figured it out... it seems that EnableViewState needed to be set to true. Does anyone know why that is?<BR><BR>Thanks,<BR>Joe
 
Back
Top