473,394 Members | 1,694 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,394 software developers and data experts.

Datagrids

Hi. I have a web form with a datagrid that displays employees who are on holiday. One of the datagrid columns shows the date of their last day of holiday, but what I really require is the Start Back at work date, i.e. if their last day of holiday is a Friday, then the Start Back date should be the following Monday (ignoring any weekends and public holiday dates).

I have a table which holds the public holiday dates (tblUKHolidays), but how do I build the datagrid to include a Start Back column. I’ve also tried building a c# method to calculate the Start Back date but I don’t know how to include this in the datagrid source.

Here is the datagrid source code without the method

private DataView CreateSource(string SortBy) {
SqlDataAdapter daGrid = new SqlDataAdapter(String.Format(@"SELECT qryFullName.FullName AS FullName, tblAbsence.dtmAbsStart AS StartDate, tblAbsence.dtmAbsEnd AS EndDate, tblAbsence.blnContactable AS Contactable, " +
"CASE " +
"WHEN tblAbsence.dtmAbsStart = '{0}' THEN tblAbsence.strAMPMStart " +
"WHEN tblAbsence.dtmAbsEnd = '{0}' AND tblAbsence.strAMPMEnd IS NOT NULL THEN tblAbsence.strAMPMEnd " +
"ELSE '' " +
"END AS AMPM " +
"FROM qryFullName INNER JOIN tblAbsence ON qryFullName.strLogonName = tblAbsence.strLogonName " +
"WHERE (tblAbsence.dtmAbsStart <= '{0}') AND (tblAbsence.dtmAbsEnd >= '{0}') AND tblAbsence.blnDeleted = 0", ActiveDate), HolData.TimeOffConn);
DataSet dsGrid = new DataSet();
daGrid.Fill(dsGrid,"Absence");
DataView vwBookings = dsGrid.Tables["Absence"].DefaultView;
vwBookings.Sort=SortBy;
return vwBookings;
}

Here is the method that I want to supply the Start Back date.

private DateTime StartBackDate(DateTime dtEndDate)
{
DateTime MyDate;
int MyDays = 0;

MyDate = dtEndDate.AddDays(1);
SqlDataAdapter daUKHolidays = new SqlDataAdapter("Select * from tblUKHolidays", HolData.TimeOffConn);
DataSet dsUKHolidays = new DataSet();
daUKHolidays.Fill(dsUKHolidays, "tblUKHolidays");
DataView dvUKHolidays = new DataView(dsUKHolidays.Tables["tblUKHolidays"]);
int rowIndex = dvUKHolidays.Find(MyDate);
while (MyDays < 1)
{
if ((MyDate.DayOfWeek.ToString() == "Monday")|(MyDate.DayOfWeek.ToString() == "Tuesday")|(MyDate.DayOfWeek.ToString() == "Wednesday")|(MyDate.DayOfWeek.ToString() == "Thursday")|(MyDate.DayOfWeek.ToString() == "Friday"))
{
if (rowIndex == -1)
{
MyDays = MyDays + 1;
}
}
if (MyDays >= 1)
break;
MyDate = MyDate.AddDays(1);;
}
return MyDate;
}
Nov 16 '05 #1
1 1317
Hi
You can create a template column , this one could be unbound and then you
create the text value of it the way you want. I had this on an App that I
have , it would look something like that .
<asp:TemplateColumn HeaderText="DVD View">
<ItemStyle BackColor="Purple"></ItemStyle>
<ItemTemplate>
<asp:Button runat="server" Text="Details" CommandName="opencontent"
CausesValidation="false"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
To create a template column by the designer , select the data grid in
design , then on the property window click on the property builder link
button .
You can also read more about his on this link

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWebUIWebControlsTemplateColumnClassTopi c.asp
hope that helps

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
In SQL Server Query Analyzer, if I type in, say, 2 select queries, it returns 2 datagrids of results, with a scrollbar on the right to scroll between the 2 (or more) datagrids. I wanted to...
1
by: Simon Harris | last post by:
Hi All, I wish to populate more than one datagrid from the same OleDBCommand. The code I have is: Dim objCmd As New OleDbCommand(strSql, objConn) Then... ...
4
by: ree32 | last post by:
I have a placeholder and depending on a user input(a drop downlist) when the user clicks a button I dynamically create a number of datagrids and fill them with data from a database. But the problem...
0
by: Scott Meddows | last post by:
I'm having trouble scrolling some datagrids so they sync up... I have two identical datagrids on a form, filled with eh same dataset. I want a user to be able to scroll on the datasets and the...
4
by: | last post by:
Hello. In SQL Server Query Analyzer, if I type in, say, 2 select queries, it returns 2 datagrids of results, with a scrollbar on the right to scroll between the 2 (or more) datagrids. I wanted to...
3
by: Mark Wiewel | last post by:
hi all, i am a newbie in ASP.NET and i couldn't find the solution to this one: i have a form with three datagrids on it. i would like to align them vertically with a space between each grid of...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
0
by: Jim | last post by:
OK here's my disclaimer: I'm very new to ASP.NET and posting on Google Groups, so please bear with me and feel free to correct either the way I code or the way I post. I have an ASP.NET page...
1
by: =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post by:
Hi, I am using the code below to export a webpage to Excel. The webpage has three datagrids on it and they are all exported to Excel properly and everything looks very nice, but we would really...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.