Bind Gridview without causing postback

Scot King 116 Reputation points
2021-06-22T00:12:13.04+00:00

I don't know why they closed forums.asp.net after so many years. Anyways, hopefully I hope to see other posters from that site over here!

I have a page with about 10 gridviews on it. Each one has a modal popup extender. On one of them I have added a column at the far left with a checkbox. in the gridview. I have javascript code that you can only select one of the checkboxes in the gridview. I'm using postback =true for the checkbox and the oncheckbox changed event handler to popuplate the grideview directly below the gridvew. When you check one of the boxes in gridview 5, it populates the gridview 6 directly below it with income information which is tied to the employer ID in the gridview 5.

There are a couple of of issues. On initial page load, the gridview 5 loads with employer data. As long as there is one row, the checkbox should be checked on the left. How is this done? In the page load event? In Rowdatabound event? When this happens, the gridview below (gridveiew 6) should load with the income that is tied to the employer in the above gridview. There can be several types of income an employer in the above gridview. I'm using the empid datakey from gridview 5 to store into a column in the income database.

Is there a way to update the gridview 6 without causing a postback? So when you check a box in gridview 5, there is no page refresh.

Protected Sub ChckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim row As GridViewRow = TryCast((CType(sender, Control)).Parent.NamingContainer, GridViewRow)
Dim key As String = GridView5.DataKeys(row.RowIndex).Value.ToString()
Dim Incomeadapter As New DataSet1TableAdapters.IncomeTableAdapter
Dim tblincome As New DataSet1.IncomeDataTable
tblincome = Incomeadapter.GetData(key)
GridView6.DataSource = tblincome
GridView6.DataBind()
End Sub

Developer technologies ASP.NET Other
{count} votes

Accepted answer
  1. Yijing Sun-MSFT 7,096 Reputation points
    2021-06-22T05:21:36.65+00:00

    Hi @Scot King ,
    If you don't want to refresh,you could use updatepanel. Child controls of the panel cause an asynchronous postback.
    https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.updatepanel?view=netframework-4.8
    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.