views:

111

answers:

2

How can I populate an editable Grid with data from different tables from MSSQL Server'05 writing a code behind function???

I have used:

    Dim conn As New SqlConnection(conn_web)
    Dim objCmd As New SqlDataAdapter(sql, conn)
    Dim oDS As New DataSet

    objCmd.Fill(oDS, "TAB")

    Dim dt As DataTable = oDS.Tables(0)
    Dim rowCount As Integer = dt.Rows.Count
    Dim dr As DataRow = dt.NewRow()
    If rowCount = 0 Then
        e.DataSource = Nothing
        e.DataBind()
        e.Focus()

    Else
        e.DataSource = dt
        e.DataBind()
    End If
A: 

I think this boils down to the e variable: What is it referencing?

I'm afraid that it's the EventArgs argument from your Page_Load method (am I right?).

In order to do what you're trying to do, it needs to refer to an instance of a GridView web control.

A: 

Your question is not much clear to me, but maybe this will help:

Write a stored procedure to fetch data from multiple tables and fill your dataset with the results that you get. Now your dataset will have a table with all the fields returned by your stored procedure, which obviously will come from different tables based on your SQL query.

Bind your grid with the dataset that you get back.

Bootcamp