torpkevuk
06-01-2006, 07:45 AM
I have a datagrid on my web app asp.net (vb.net 2003 used to make it) connected to an MS SQL Server
I populate my datagrid like this:
Public Sub CheckForInvAdj()
intRASNum = Request.QueryString("RAS")
Me.ViewState("RAS") = intRASNum
Dim myConnectionIT As New System.Data.SqlClient.SqlConnection(myITConnString)
myConnectionIT.Open()
'Populate datagrid with all inventory adjustments for this RAS
Dim dgrSQL As String = "SELECT InvAdj_id, System_id, SKU_id "
' There are some more fields, but I dont want the page to wrap
dgrSQL += "FROM MyTable "
dgrSQL += "WHERE Incident_id = '" & intRASNum & "' ORDER BY InvAdj_id"
Dim myCommand As New System.Data.SqlClient.SqlCommand(dgrSQL, myConnectionIT)
Dim myReader As System.Data.SqlClient.SqlDataReader = myCommand.ExecuteReader()
Dim rowCnt As Integer = 0
If myReader.HasRows Then
Do While myReader.Read()
rowCnt += 1
Loop
End If
myReader.Close()
dgrAllCom.VirtualItemCount = rowCnt
If dgrAllCom.VirtualItemCount = 0 Then
' If there are no records, hide the datagrid
myConnectionIT.Close()
dgrAllCom.VirtualItemCount = False
Exit Sub
End If
'at least one record was found
Dim ds As New DataSet
Dim da As New System.Data.SqlClient.SqlDataAdapter(dgrSQL, myConnectionIT)
da.Fill(ds, dgrAllCom.CurrentPageIndex * dgrAllCom.PageSize, dgrAllCom.PageSize, "IT_Incident_InvAdj")
dgrAllCom.Visible = True
dgrAllCom.DataSource = ds.Tables("MyTable")
dgrAllCom.DataKeyField = "InvAdj_id"
dgrAllCom.DataBind()
myConnectionIT.Close()
End Sub
What I want to do though, is drop the first column, which is a link to Edit each individual record.
I thought maybe the .Columns.Remove but I cant seem to get it working
any help would be appreciated
thanks
I populate my datagrid like this:
Public Sub CheckForInvAdj()
intRASNum = Request.QueryString("RAS")
Me.ViewState("RAS") = intRASNum
Dim myConnectionIT As New System.Data.SqlClient.SqlConnection(myITConnString)
myConnectionIT.Open()
'Populate datagrid with all inventory adjustments for this RAS
Dim dgrSQL As String = "SELECT InvAdj_id, System_id, SKU_id "
' There are some more fields, but I dont want the page to wrap
dgrSQL += "FROM MyTable "
dgrSQL += "WHERE Incident_id = '" & intRASNum & "' ORDER BY InvAdj_id"
Dim myCommand As New System.Data.SqlClient.SqlCommand(dgrSQL, myConnectionIT)
Dim myReader As System.Data.SqlClient.SqlDataReader = myCommand.ExecuteReader()
Dim rowCnt As Integer = 0
If myReader.HasRows Then
Do While myReader.Read()
rowCnt += 1
Loop
End If
myReader.Close()
dgrAllCom.VirtualItemCount = rowCnt
If dgrAllCom.VirtualItemCount = 0 Then
' If there are no records, hide the datagrid
myConnectionIT.Close()
dgrAllCom.VirtualItemCount = False
Exit Sub
End If
'at least one record was found
Dim ds As New DataSet
Dim da As New System.Data.SqlClient.SqlDataAdapter(dgrSQL, myConnectionIT)
da.Fill(ds, dgrAllCom.CurrentPageIndex * dgrAllCom.PageSize, dgrAllCom.PageSize, "IT_Incident_InvAdj")
dgrAllCom.Visible = True
dgrAllCom.DataSource = ds.Tables("MyTable")
dgrAllCom.DataKeyField = "InvAdj_id"
dgrAllCom.DataBind()
myConnectionIT.Close()
End Sub
What I want to do though, is drop the first column, which is a link to Edit each individual record.
I thought maybe the .Columns.Remove but I cant seem to get it working
any help would be appreciated
thanks