How to get title of a columnt in TListView control? - autoit

All I know is ControlListView function: http://www.autoitscript.com/autoit3/docs/functions/ControlListView.htm
and there is an option GetText with two parameters for row and column but there I can't see anything to get the text of column heading, that is the place where user can click by mouse and for example sort by that column etc.

You could try using _GUICtrlListView_GetColumn. This function returns an array with information about the given ListView column.
Local $aCol = _GUICtrlListView_GetColumn($lvwMsgTable, 0)
ConsoleWrite('Title of column 0: ' & $aCol[5] & #LF)
$aCol = _GUICtrlListView_GetColumn($lvwMsgTable, 1)
ConsoleWrite('Title of column 1: ' & $aCol[5] & #LF)
$aCol = _GUICtrlListView_GetColumn($lvwMsgTable, 2)
ConsoleWrite('Title of column 2: ' & $aCol[5] & #LF)
I don't know if this is working with a TListView though.

Related

Multiple Where Parameters on EntityDataSource?

I have a gridview that uses an entity datasource to populate itself. Depending on what the user has access to see, I want the gridview to implement a where clause. At the lowest level of access, the user can only see themselves. In order to do this I implement the line of code:
EmployeeEntityDataSource.Where = "it.Person_ID = " + selectQuery.ToString()
This successfully reduces the data in the gridview to the one appropriate user. If the user has the next step in access, they should be able to see themselves plus all the employees that work for them. I have sucessfully created a list of employees Person_IDs and I'm trying to filter my gridview so that if the Person_ID column in the gridview matches one of the Person_IDs in my list it should show up.
I have tried the following bits of code:
1.
For Each employeeID In employeeList
If count2 <> count Then
whereString += "it.Person_ID = " + employeeID.ToString() + " OR "
count2 += 1
Else
whereString += "it.Person_ID = " + employeeID.ToString()
End If
Next
EmployeeEntityDataSource.Where = whereString
Essentially thought I could create a giant where statement with a bunch of ORs but this did not work
2.
EmployeeEntityDataSource.WhereParameters.Add(employeeList)
EmployeeEntityDataSource.Where = "it.Person_ID = #employeeList"
The error I get here says a List(of T) cannot be converted WebControl.Parameter
How do I properly create a WHERE statement that will compare the it.Person_ID of the gridview to each element in my list called employeeList?
I think an In statement should accomplish what you need. Something like this -
string employeeIDs = string.Join(",", employeeList.ToList());
EmployeeEntityDataSource.Where = String.Format("it.Person_ID IN ({0})", employeeIDs);
Or you may have to iterate through your list to create the employeeIDs string, depending on the types we're dealing with here.
Apparently I lied When I said my first bit of code did not work. The issue was that I was not generating the massive OR statement correctly.
From what I remember the statement I was originally generating was it.Column = ID1 OR ID2 OR ID3 and so on.
If the statement created is it.Column = ID1 OR it.Column = ID2 OR it.Column = ID3 and so on, this creates a statement that works properly.
The code that is working in my current project is:
For Each employee In employeeList
If count2 <> count Then
whereString += "it.Person_ID = " + employee.ToString() + " OR "
count2 += 1
Else
whereString += "it.Person_ID = " + employee.ToString()
End If
Next
EmployeeEntityDataSource.Where = whereString

loop through two different html tables

I am searching for the answer for the whole day.
Basically, I have two html tables and a recordset in getrows()
The page is designed so that there are two html tables and I need to generate it, no other choice to re-design the page :(
Here are the html tables. They are horizontally aligned.
table1 table2
row row
row row
row row
and so on...
How can I generate these tables and of course I do not know how many records are in the recordset.
lets assume that there are 3 fields, name, quantity and date. so, there will be two html tables and i get six columns, three of each table. i will not distribute different fields to different tables. so tables are just the same, side by side, with different data on them, not the fields
You can create a "container table" that will have the two side-by-side tables within so that they lay out as you desire. You didn't specify, so I have table 1 with the first half of the data, and table 2 with the second half. (It's a bit easier/more straightforward, but you can do it with only a little extra effort to have row 1 in table 1, row 2 in table 2, row 3 in table 1, row 4 in table 2, etc.)
So, starting from the array of your records obtained via GetRows (arrData in my example below), and assuming your array has them in the order (from left to right) you want them displayed:
Response.Write "<table><tr><td>"
dim intLastRow
intLastRow = ubound(arrData, 2)
dim intBreakPoint
intBreakPoint = fix(intLastRow/2)
dim intSecondStartPoint = intBreakPoint + 1
Response.Write "<table>"
dim i
for i = 0 to intBreakPoint
Response.Write "<tr><td>" & arrData(0, i) & "</td><td>" & arrData(1, i) & "</td><td>" & arrData(2, i) & "</td></tr>"
next
Response.Write "</table>"
if intLastRow > 0 then
Response.Write "<table>"
for i = intSecondStartPoint to intLastRow
Response.Write "<tr><td>" & arrData(0, i) & "</td><td>" & arrData(1, i) & "</td><td>" & arrData(2, i) & "</td></tr>"
next
Response.Write "</table>"
end if
Response.Write "</td></tr></table>"

How to add a div after every 5 rows of data?

I'm trying to add div after a group of 5 rows of data inside Listview.
I came up with using Mod 5 = 0 but I realized the last row is missing if total row count can't divided by 5.
For example, I have 11 rows of data.
"Div" will be added after 5 and 10.
I also need to add "Div" after 11 as well. (div will display details of each group)
So, something like this
1|2|3|4|5
DIV1
6|7|8|9|10
DIV2
11|
Div3(missing)
Here is inline code I have so far
<%# IIf((Container.DisplayIndex + 6) Mod 5 = 0, "<div id='temp" + Math.Floor((Container.DisplayIndex + 6) / 5).ToString + "' style='display:none'></div>", "")%>
How do I add the last div when total # can't be divided by 5?
I have to get the total# of display index somehow...
You can compare it with the ListView.Items.Count property.
This should work:
Dim addDiv = (Container.DisplayIndex Mod 5 = 0) OrElse _
(Container.DisplayIndex + 1 = ListView1.Items.Count)
If you are using paging you should use DataItemIndex instead of DisplayIndex.
Edit: (according to your last comment)
If you need to show the total record count you have to cast the ListView's DataSource to it's correct type(f.e. a DataTable).
Dim tbl as DataTable = DirectCast(ListView1.DataSource, DataTable)
Dim totalCount as Int32 = tbl.Rows.Count
or in one line:
DirectCast(ListView1.DataSource, DataTable).Rows.Count
But this works only on databinding and not on every postback because the DataSource will be disposed at the end of the Page-Lifecycle.
the "+6" makes it look like you're guessing around how the modulo function works :)
try this:
<%# IIf(Container.DisplayIndex Mod 5 = 4 Or Container.DisplayIndex = ListView.Items.Count , "<div id='temp" + (1+Math.Floor(Container.DisplayIndex/5)).ToString + "' style='display:none'></div>", "")%>
so first (index+6)%5 == 0 is the same as index%5 == 4,
second floor((index+6)/5) results in 2 when index=4, this is not what you want.
using 1+floor(index/5) will give you the correct results --- you could even drop the "1+" if you want the index to start from 0.
(p.s. i don't know asp.net, sorry if there's compiler errors)

Linq to SQL: Group By and Sum()

I'm very new to linq so this should be pretty easy to answer, but I've had a hard time finding the answer.
I have the following LINQ statement, which performs a simple linq query and assigns the resulting values labels on an asp.net web form:
Dim db As New MeetingManagerDataContext
Dim q = From s In db.vwRoomAvailabilities _
Where s.MeetingID = lblMeetingID.Text _
Select s.AllRequestedSingles, s.AllRequestedDoubles, s.AllBookedSingles, s.AllBookedDoubles, SinglesNeeded = s.AllRequestedSingles - s.AllBookedDoubles, DoublesNeeded = s.AllRequestedDoubles - s.AllBookedDoubles
lblSinglesRequested.Text = "Singles Requested: " & q.FirstOrDefault.AllRequestedSingles
lblSinglesBooked.Text = "Singles Booked: " & q.FirstOrDefault().AllBookedSingles
lblSinglesNeeded.Text = "Singles Needed: " & q.FirstOrDefault().SinglesNeeded
lblDoublesRequested.Text = "Doubles Requested: " & q.FirstOrDefault().AllRequestedDoubles
lblDoublesBooked.Text = "Doubles Booked: " & q.FirstOrDefault().AllBookedDoubles
lblDoublesNeeded.Text = "Doubles Needed: " & q.FirstOrDefault().DoublesNeeded
Originally, there was going to be only a single row result and you can see I'm using FirstOrDefault() to grab that single value which works great. But the design has changed, and multiple rows can now be returned by the query. I need to now Group By the MeetingID above, and SUM each of the selected columns (i.e. s.AllRequestedDoubles).
I've found lots of grouping and summing samples but none seem to fit this scenario very well.
Can you help me modify the above LINQ to Sum the resulting values instead of just showing the first row result values?
Try this
From s In db.vwRoomAvailabilities
Where s.MeetingID = lblMeetingID.Text
Group by s.MeetingID
into SumAllRequestedDoubles = sum(s.AllRequestedDoubles),
SumAggregate2 = sum(s.SomeField2),
SumAggregate3 = sum(s.SomeField3)
Select SumAllRequestedDoubles, SumAggregate2, SumAggregate3
That will get you started for performing a SUM on that single column.
You'll need to project each SUM'd column into a new aliased column (like i did above).
Also, as you're new to LINQ-SQL, check out LinqPad - it will rock your world.

Index of the current DataRow in a DataTable

For Each dr As myDAL.UsersRow In data
str.AppendLine(dr.UserName)
Next
In the above code, I also need to include the row index so that it's something like
str.AppendLine(dr.IndexNumber & " " & dr.UserName)
How can I achieve this?
P.S. data is not a DataTable but a generic list of myDAL.UsersRow
If data is a List<myDAL.UsersRow> as you suggest, you can use a "for" loop rather than a "for each" loop:
for i = 0 to data.Count - 1
str.AppendLine(i & " " & data[i].UserName)
next
If, however, you're implying that your "data" list is not in the same order as the original DataTable's rows, you might be able to use the DataRowCollection.IndexOf method to locate the row in the original table:
for each dr as myDAL.UsersRow in data
str.AppendLine(dr.Table.Rows.IndexOf(dr) & " " & dr.UserName)
next
Declare a counter variable before the ForEach loop, and increment it inside it.
Dim counter As Integer = 0
For Each dr As myDAL.UsersRow In data
counter = counter + 1
str.AppendLine(counter.ToString() & " " & dr.UserName)
Next

Resources