Hi All Experts,

Actually I am VB.Net Windows Application Developer Now i am going an ASP.Net Application. So, the Problem is that in Windows Application i Code this Project like given Below Actually i am Using SQL Server as DataBase and Store Procedure as Query.
Becuase i had tried to control the ASP.Net Data Grid with Loop and i Failed to Control it with this method so can any one Help me.
(Can any one Help that how can i Solve this Problem in ASP.Net)

Private Sub btn_Ok_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles btn_Ok.Click
Fill_dataset("Sel_MovNames", "Tbl_MovNames", Convert.toint32(cmb_MovID.SelectedValue))
      For rowcnt As Integer = 0 To ds.Tables("Tbl_MovNames").Rows.Count - 1
        dg_Movies.Item("col_SrNo", dg_Movies.RowCount - 2).Value = rowcnt + 1
        dg_Movies.Item("col_MovID", dg_Movies.RowCount - 2).Value = ds.Tables("Tbl_MovNames").Rows(rowcnt)("MovID").ToString
        dg_Movies.Item("col_MovName", dg_Movies.RowCount - 2).Value = ds.Tables("Tbl_MovNames").Rows(rowcnt)("MovName").ToString
        dg_Movies.Item("col_MovYear", dg_Movies.RowCount - 2).Value = ds.Tables("Tbl_MovNames").Rows(rowcnt)("MovYear").ToString
        dg_Movies.Item("col_MovViews", dg_Movies.RowCount - 2).Value = ds.Tables("Tbl_MovNames").Rows(rowcnt)("Views").ToString
 End Sub
Private Sub Fill_dataset(ByVal SPName As String, ByVal TableName As String, ByVal arg1 As Integer)
        SPName = SPName & " '" & arg1 & "'"
        myAdapter = New SqlDataAdapter(SPName, SQLCon)
        myAdapter.Fill(ds, TableName)
        myAdapter.Fill(ds, TableName)
End Sub

I guess using the following will be much easier.

dg_Movies.DataSource = ds.Tables("Tbl_MovNames").DefaultView()
Be a part of the DaniWeb community

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