Tom Chesley
Member
- Joined
- Jun 18, 2006
- Messages
- 12
- Programming Experience
- 1-3
I currently have a sql 2000 database with a list of users and I can display a datagrid on my web with all of the users, the problem is I now want to display like 4 columns of the users so i dont have to scroll down on my web page
Say for instance I have 5 users
user1
user2
user3
user4
user5
I want to see
user1 user2 user3 user4
user5
Is that possible?
my current vb code is
Say for instance I have 5 users
user1
user2
user3
user4
user5
I want to see
user1 user2 user3 user4
user5
Is that possible?
my current vb code is
VB.NET:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim cmd As String = "SELECT UserName "
'set Focus on textbox
Page.RegisterStartupScript("SetFocus", _
"<script>document.getElementById('" & txtBadGuy.ClientID & _
"').focus();</script>")
cmd &= "FROM MyUsers ORDER BY UserName"
DO_Cmd(cmd)
dg.Caption = "Users"
dg.DataBind()
End Sub
Private Sub DO_Cmd(ByVal cmd)
Dim Count As Integer
Dim RowsCnt As Integer
Dim Extras As Integer
'create SQL command
Dim selCmd As New SqlClient.SqlCommand(cmd)
'create data adapter
Dim PTAdapter As New SqlClient.SqlDataAdapter(selCmd)
'set the connector to the adapter
PTAdapter.SelectCommand.Connection = con
'create dataset
Dim ds As New DataSet
Try
'fill data adapter
PTAdapter.Fill(ds, "UserName")
'bind the datagrid
dg.DataSource = ds
dg.DataMember = "UserName"
Catch ex As Exception
lblError.Text = ex.Message
Finally
con.Close()
End Try
Count = ds.Tables(0).Rows.Count
RowsCnt = Count / 4
Extras = Count - RowsCnt * 4
lblCnt.Text = "We have " & Count & " so far"
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
lblRammer.Visible = True
txtBadGuy.Visible = True
btnSubmit.Visible = True
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim UpdateCMD As SqlClient.SqlCommand
Dim UpdatePT As String = "INSERT INTO MyUsers VALUES ("
UpdatePT &= "'" + txtUser.Text + "')"
UpdateCMD = New SqlClient.SqlCommand(UpdatePT, con)
Try
con.Open()
UpdateCMD.ExecuteNonQuery()
Catch ex As Exception
lblError.Text = ex.Message
Finally
con.Close()
End Try
Response.Redirect("http://localhost/PT/PT.aspx")
End Sub
Private Sub dg_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg.DataBinding
'Stop
End Sub
Private Sub dg_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemCreated
'Dim test As String
'test = dg.Items.Item(1).DataItem
'Stop
End Sub