How can i select certain columns from a stored procedure, lets say i just want 2 of the 10 columns
item and total sales.
Dim reader As SqlDataReader
cmd.Parameters.AddWithValue("@yeartoget", DropDownList1.SelectedValue)
If RadioButtonList1.SelectedIndex = "0" Then
cmd.CommandText = "asofsales"
ElseIf RadioButtonList1.SelectedIndex = "1" Then
cmd.CommandText = "asofnetsales"
End If
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = conn
conn.Open()
reader = cmd.ExecuteReader()
GridView1.DataSource = reader
GridView1.DataBind()
conn.Close()
Just specify the columns you want and turn off the autogeneration.
You could also read the results into a datatable and delete the columns you don’t want or do it with linq but that’s just overkill unless you need to fiddle with the data further before displaying it