Need advice for ASP.NET Grid[checkbox]
<p>I created a web app. And now, I'm having problem with it. I used Grid with checkbox. I have a scenario that when the user select a data to save in the database, they tick the checkbox in the grid. Now, the problem is when I save the data. It takes 3-5mins to save. Is there another way to optimize it? Here's my code</p>

<pre><code>    For Each oGridItem In dgObj.Items
        Dim oCheck As CheckBox = oGridItem.FindControl("chkSelect1")
        If oCheck.Checked = True Then
            Try 
            If AppType.Text = 124 Then
                WebCtrl.strCommand = "EXEC spFilterUnLiquidation '" &amp; AppType.Text &amp; "', '" &amp; GetGridItem("AppId").Text &amp; "', '" &amp; dgObj.DataKeys(oGridItem.ItemIndex) &amp; "', '" &amp; GetCompanyId &amp; "' SET DATEFORMAT mdy EXEC spUpdateUnliquidate '" &amp; GetGridItem("AppId").Text &amp; "', '" &amp; dgObj.DataKeys(oGridItem.ItemIndex) &amp; "', " &amp; GetGridItem("DiffAmnt").Text &amp; ", '" &amp; GetCompanyId &amp; "' "
            Else
                WebCtrl.strCommand = "EXEC spFilterLiquidation '" &amp; AppType.Text &amp; "', '" &amp; GetGridItem("AppId").Text &amp; "', '" &amp; dgObj.DataKeys(oGridItem.ItemIndex) &amp; "', '" &amp; GetCompanyId &amp; "' "
            End If

        Catch Exp As Exception
            WebCtrl.SetMessage(Exp)
            GoTo RollBack
        End Try

        WebCtrl.strCommand = "SELECT AppId FROM _temp WHERE AppId = '" &amp; GetGridItem("AppId").Text &amp; "' "
        If WebCtrl.dsCount() &gt; 0 Then
            WebCtrl.strCommand = "DELETE FROM _temp WHERE Liquidator = '" &amp; txtLiqId.Text &amp; "' "
            WebCtrl.strCommand = "INSERT INTO _temp SELECT * FROM APP_OCAE WHERE AppId = '" &amp; GetGridItem("AppId").Text &amp; "' "
        Else
            WebCtrl.strCommand = "INSERT INTO _temp SELECT * FROM APP_OCAE WHERE AppId = '" &amp; GetGridItem("AppId").Text &amp; "' "
        End If

        WebCtrl.strCommand = "SELECT AppId FROM _temp1 WHERE AppId = '" &amp; GetGridItem("AppId").Text &amp; "' AND LineId = '" &amp; dgObj.DataKeys(oGridItem.ItemIndex) &amp; "' "
        If WebCtrl.dsCount() &gt; 0 Then
            WebCtrl.strCommand = "INSERT INTO _temp1 SELECT * FROM APP_CAE1 WHERE AppId = '" &amp; GetGridItem("AppId").Text &amp; "' AND LineId = '" &amp; dgObj.DataKeys(oGridItem.ItemIndex) &amp; "' "
        Else
            WebCtrl.strCommand = "INSERT INTO _temp1 SELECT * FROM APP_CAE1 WHERE AppId = '" &amp; GetGridItem("AppId").Text &amp; "' AND LineId = '" &amp; dgObj.DataKeys(oGridItem.ItemIndex) &amp; "' "
        End If 

        oCtr += 1
        oAppId(oCtr) = GetGridItem("AppId").Text
        oAppNo(oCtr) = GetGridItem("AppNo").Text
        End If
    Next
</code></pre>

<p>In my code, I check first what are the row that are checked and include it to my database. But what if I have 100 records, the loop will look all the row in my grid. Which I think that's the bottleneck. :(</p>
