I recently discovered the power of Linq To SQL and decided to implement it into a control that I am working on right now. So far it is making life much easier but I have ran into a small stumbling block here and need the experts assistance. I have a gridview bound to a LinqDataSource and enabled updating on the linq datasource. Everything binds just fine. In my Database I have a boolean field that I have display as a checkbox in the gridview. I set my gridview up with template fields to always have the checkbox enabled and also included an Update button next to the checkbox. When I check/uncheck the box and update Linq does its work and modifies the DB just like it should. The issue is i dont get ANY events fired. RowCommand, Updating, Inserting NOTHING. On both the Linq and the Gridview. I set up a temp label and had it append the Text when events fire...nothing displays. How can I detect this update so I can push a Gridview.DataBind again? :(...IDK if it makes a difference but I am using a master.page all wrapped in an update panel.

Protected Sub gvHR_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles gvHR.RowUpdated
        gvHR.DataBind()
        Label1.Text += " hr row updated "
    End Sub

    Protected Sub gvHR_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvHR.RowUpdating
        Label1.Text += " hr row updating "
    End Sub

    Protected Sub ldsHR_ContextCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles ldsHR.ContextCreated
        Label1.Text += " lds contex created "
    End Sub

    Protected Sub ldsHR_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles ldsHR.DataBinding
        Label1.Text += " lds databinding "
    End Sub

    Protected Sub ldsHR_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles ldsHR.Inserted
        Label1.Text += " lds row inserterd "
    End Sub

    Protected Sub ldsHR_Updated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles ldsHR.Updated
        gvHR.DataBind()
        Label1.Text += " lds row updated "
    End Sub

    Protected Sub ldsHR_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceUpdateEventArgs) Handles ldsHR.Updating
        Label1.Text += " lds row updating "
    End Sub

    Protected Sub gvHR_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvHR.RowCommand
        Label1.Text = e.CommandName.ToString
end sub

Recommended Answers

All 2 Replies

It doesn;t matter whatever you are using and control resides within update panel, Event should have to fire..

Can you please show code of your Gridview from aspx page ? have you defined events correctly in gridview ?


I recently discovered the power of Linq To SQL and decided to implement it into a control that I am working on right now. So far it is making life much easier but I have ran into a small stumbling block here and need the experts assistance. I have a gridview bound to a LinqDataSource and enabled updating on the linq datasource. Everything binds just fine. In my Database I have a boolean field that I have display as a checkbox in the gridview. I set my gridview up with template fields to always have the checkbox enabled and also included an Update button next to the checkbox. When I check/uncheck the box and update Linq does its work and modifies the DB just like it should. The issue is i dont get ANY events fired. RowCommand, Updating, Inserting NOTHING. On both the Linq and the Gridview. I set up a temp label and had it append the Text when events fire...nothing displays. How can I detect this update so I can push a Gridview.DataBind again? :(...IDK if it makes a difference but I am using a master.page all wrapped in an update panel.

Protected Sub gvHR_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles gvHR.RowUpdated
        gvHR.DataBind()
        Label1.Text += " hr row updated "
    End Sub

    Protected Sub gvHR_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvHR.RowUpdating
        Label1.Text += " hr row updating "
    End Sub

    Protected Sub ldsHR_ContextCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles ldsHR.ContextCreated
        Label1.Text += " lds contex created "
    End Sub

    Protected Sub ldsHR_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles ldsHR.DataBinding
        Label1.Text += " lds databinding "
    End Sub

    Protected Sub ldsHR_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles ldsHR.Inserted
        Label1.Text += " lds row inserterd "
    End Sub

    Protected Sub ldsHR_Updated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs) Handles ldsHR.Updated
        gvHR.DataBind()
        Label1.Text += " lds row updated "
    End Sub

    Protected Sub ldsHR_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceUpdateEventArgs) Handles ldsHR.Updating
        Label1.Text += " lds row updating "
    End Sub

    Protected Sub gvHR_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvHR.RowCommand
        Label1.Text = e.CommandName.ToString
end sub

I have been out of the office for a few days and didn't get a chance to update this yet but the issue was resolved by adding

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
if Not ispostback then
gvHR.DataBind()
end if
End Sub

It seems to be a requirement to re-bind the controls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.