473,379 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

arraylist with autogenerated column and databound?

1


Hi,
I have the auto generated dayName and date out... mean the top 2 rows out but now i need to get the name of employee from the sql database... After coding, the name came out as horizontal but i wan vertical is this possible???

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2. Imports System.Data
  3. Partial Class Test
  4.     Inherits System.Web.UI.Page
  5.     Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ScheduleForm.mdb")
  6.     Sub TakeoutOutlets()
  7.         cnn.Open()
  8.         Dim cmd As New OleDbCommand
  9.         cmd.CommandText = "Select * from Outlets Order By OutletName"
  10.         cmd.Connection = cnn
  11.         Dim da As New OleDbDataAdapter(cmd)
  12.         Dim ds As New DataSet
  13.         da.Fill(ds)
  14.         ddl_out.DataValueField = "OutletName"
  15.         ddl_out.DataTextField = "OutletName"
  16.         ddl_out.DataSource = ds
  17.         ddl_out.DataBind()
  18.         cnn.Close()
  19.     End Sub
  20.        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  21.  
  22.         If Not IsPostBack Then
  23.             TakeoutOutlets()
  24.             For i As Integer = DateTime.Now.Year To DateTime.Now.Year + 9
  25.                 'Populate DropDownList 
  26.                 'Year 
  27.                 Me.DropDownList1.Items.Add(New ListItem(i.ToString(), i.ToString()))
  28.             Next
  29.             For i As Integer = 1 To 12
  30.                 'Month 
  31.  
  32.                 Me.DropDownList2.Items.Add(New ListItem(i.ToString(), i.ToString()))
  33.             Next
  34.         End If
  35.     End Sub
  36.  
  37.     Protected Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
  38.  
  39.         If DropDownList1.SelectedItem.Text = "Select a Year" Or DropDownList2.SelectedItem.Text = "Select a month" Then
  40.             emsg.Text = "Please select a month and a year"
  41.         Else
  42.             Dim year As Integer = Convert.ToInt32(Me.DropDownList1.SelectedValue)
  43.             Dim month As Integer = Convert.ToInt32(Me.DropDownList2.SelectedValue)
  44.             Dim day_num As Integer = DateTime.DaysInMonth(year, month)
  45.             Dim a As New ArrayList()
  46.  
  47.             Dim datelist As New ArrayList()
  48.             Dim daylist As New ArrayList()
  49.             Dim name As New ArrayList()
  50.             For i As Integer = 1 To day_num
  51.                 Dim dt As New DateTime(year, month, i)
  52.                 datelist.Add(dt.ToString("ddd"))
  53.  
  54.  
  55.                 daylist.Add(dt.ToString("dd"))
  56.  
  57.             Next
  58.             cnn.Open()
  59.             Dim sqlstr As String = "Select * from Schedule where outlets = '" + ddl_out.SelectedItem.Text + "'"
  60.             Dim cmd As New OleDbCommand(sqlstr, cnn)
  61.             Dim objDR As OleDbDataReader
  62.             objDR = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
  63.             While objDR.Read()
  64.                 name.Add(objDR("EmpID"))
  65.             End While
  66.             cnn.Close()
  67.             a.Add(datelist)
  68.             a.Add(daylist)
  69.             a.Add(name)
  70.             Me.GridView4.DataSource = a
  71.             Me.GridView4.DataBind()
  72.         End If
  73.         End Sub
  74.  
  75.     Protected Sub GridView4_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
  76.         Dim a As ArrayList = TryCast(e.Row.DataItem, ArrayList)
  77.         e.Row.Cells.Clear()
  78.         If a IsNot Nothing Then
  79.             For Each s As String In a
  80.                 Dim tc As New TableCell()
  81.                 tc.Text = s
  82.                 e.Row.Cells.Add(tc)
  83.             Next
  84.         End If
  85.     End Sub
  86. End Class
Oct 30 '07 #1
1 1083
nateraaaa
663 Expert 512MB
I don't understand what you are asking. Are you saying that the employeeName was a long string concatenated together in your dropdownlist? Please clarify your problem and what you want to accomplish.

Nathan
Oct 30 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Dan V. | last post by:
I would like to create a 2D string list (2D ArrayList ???). I would like to pass in a table or query as a parameter and have both columns transform into a 2D ArrayList. When I sort the one...
3
by: Binny | last post by:
I have a DG with autogenerated columns. can i make a column readonly like the data key column. Thanks
8
by: Binny | last post by:
I have a DG with autogenerated columns. can i make a columns readonly like the data key column. when edititemindex is valid. Thanks
2
by: jax | last post by:
Hi All developers ! I have a datagrid which autogenerates columns by the sql SELECT list... The list (for some reasons) must be the same. So my question is HOW TO MOVE OUT A COLUMN FROM...
0
by: Luis Esteban Valencia | last post by:
Once a user clicks "add new row", a new row is created in my Datagrid. The datasource is huge so they have to scroll to the bottom of the page to edit the data in the new row. I have come across...
9
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
3
by: sck10 | last post by:
Hello, I am trying to bind an arraylist to a FormView DropDownList control in the PreRender state. The error that I get is the following: Databinding methods such as Eval(), XPath(), and...
3
by: bbawa1 | last post by:
I have a Grid View and I want to sort the data in Gridview by clicking on column. How can I do that.
4
by: StinkyDuck | last post by:
I'm trying to determine which type of collection to use, DataTable or ArrayList. I understand that an ArrayList can be linked to databound objects if it contains the IList interface. Is there a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.