Click here to Skip to main content
16,011,542 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCustom Validator for validate string Pin
ybasha17-Sep-07 16:13
ybasha17-Sep-07 16:13 
AnswerRe: Custom Validator for validate string Pin
ybasha17-Sep-07 16:57
ybasha17-Sep-07 16:57 
GeneralRe: Custom Validator for validate string Pin
ybasha17-Sep-07 17:51
ybasha17-Sep-07 17:51 
AnswerRe: Custom Validator for validate string Pin
ybasha17-Sep-07 19:46
ybasha17-Sep-07 19:46 
QuestionReading HTML Pin
Saksida Bojan17-Sep-07 11:26
Saksida Bojan17-Sep-07 11:26 
AnswerRe: Reading HTML Pin
ChrisKo17-Sep-07 12:43
ChrisKo17-Sep-07 12:43 
GeneralRe: Reading HTML Pin
Saksida Bojan17-Sep-07 23:12
Saksida Bojan17-Sep-07 23:12 
QuestionPass values in nested gridview Pin
shrihit17-Sep-07 10:27
shrihit17-Sep-07 10:27 
I try to display data of all employees weekly report. I am using nested gridview, where i need to pass Userid from parent to child gridview so that it display the data according to Userid.

Can some help me on this to pass the values?

Here is my code:

Protected Sub btnook_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOOk.Click
Dim strsql As String = ""
Dim strsdate As String = String.Format("{0Big Grin | :-D }", TextBox1.Text)
Dim stredate As String = String.Format("{0Big Grin | :-D }", TextBox2.Text)

parentgrid(strsdate, stredate)
MsgBox("after function called")

End Sub



Public Function parentgrid(ByVal stsdate As String, ByVal stedate As String) As DataSet

Dim strsdate As String = String.Format("{0Big Grin | :-D }", stsdate)
Dim stredate As String = String.Format("{0Big Grin | :-D }", stedate)
'Dim struser As String = user

Try
strsql = "SELECT b.Userid, sum(format(b.Time2 - a.Time1, ""h.mm"")) AS TotalTime FROM " _
& "(select Userid, num,TimeStamp as time2, pdate from PunchClock " _
& "where InOut='IN' AND PDate >= #" & strsdate & "# And PDate <= #" & stredate & "# " _
& " ORDER BY timestamp) AS b INNER JOIN " _
& "(select Userid, num,TimeStamp as time1, pdate from PunchClock " _
& "where InOut='OUT' AND PDate >= #" & strsdate & "# And PDate <= #" & stredate & "# " _
& "ORDER BY timestamp) AS a ON (b.num = a.num) AND (b.pdate=a.pdate) and (b.Userid=a.Userid) group by b.userid;"

'Opening the database
cmd.CommandType = CommandType.Text
cmd.CommandText = strsql
cmd.Connection = con
con.Open()
MsgBox("Main" & strsql)

objReader = cmd.ExecuteReader
MsgBox("Out2:" & strsql)

da = New OleDbDataAdapter(strsql, con)
ds = New DataSet("Userdetail")
dt = ds.Tables.Add(strsql)
da.Fill(ds, strsql)
con.Close()

ParentGridView.DataSource = ds
ParentGridView.DataBind()

Catch ex As Exception
MsgBox("oops: " & ex.Message, MsgBoxStyle.OkOnly, "Error")
con.Close()
End Try

Return ds

End Function


Protected Sub ParentGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles ParentGridView.RowDataBound

Dim strsdate As String = String.Format("{0Big Grin | :-D }", TextBox1.Text)
Dim stredate As String = String.Format("{0Big Grin | :-D }", TextBox2.Text)


If e.Row.RowType = DataControlRowType.DataRow Then
Dim gv As GridView
gv = e.Row.FindControl("ChildGridView")
Dim struser As String
struser = e.Row.FindControl("EmpName").ToString()
Try

strsql = "SELECT b.Userid, Format([b.PDate],""m/d/yyyy"") AS PDate, b.Time2, " _
& "b.InOut as TIN, a.Time1, a.InOut as TOUT, format(b.Time2 - a.Time1, ""h.mm"") AS TotalTime FROM " _
& "(select Userid, PDate, num, TimeStamp as time2, InOut from PunchClock " _
& "where Userid='" & struser & "' AND InOut='IN' AND PDate >= #" & strsdate & "# And PDate <= #" & stredate & "# " _
& "ORDER BY PDate, timestamp) AS b INNER JOIN " _
& "(select Userid, PDate, num, TimeStamp as time1, InOut from PunchClock " _
& "where Userid='" & struser & "' AND InOut='OUT' AND PDate >= #" & strsdate & "# And PDate <= #" & stredate & "# " _
& "ORDER BY PDate, timestamp) AS a ON (b.num = a.num) AND (b.pdate=a.pdate) " _
& "group by b.userid, b.PDate, b.time2, a.time1, a.InOut, b.InOut " _
& "ORDER BY b.PDate, b.time2, a.time1;"

'Opening the database
cmd.CommandType = CommandType.Text
cmd.CommandText = strsql
cmd.Connection = con
con.Open()
MsgBox("Parent" & strsql)

objReader = cmd.ExecuteReader
MsgBox("Out2:" & strsql)

da = New OleDbDataAdapter(strsql, con)
ds = New DataSet("Fulldeatils")
dt = ds.Tables.Add(strsql)
da.Fill(ds, strsql)
con.Close()

gv.DataSource = ds
gv.DataBind()

Catch ex As Exception
MsgBox("oops: " & ex.Message, MsgBoxStyle.OkOnly, "Error")
con.Close()
End Try
End If
End Sub





HTML:



<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>





<title>Untitled Page





 <asp:label id="Label8" runat="server" text="Start Date:" width="104px"> 
<asp:textbox id="TextBox1" runat="server" width="112px"> 
<asp:imagebutton id="ImageButton1" runat="server" imageurl="~/Images/calendar.jpg"
="" width="24px"> <asp:calendar id="Calendar1" runat="server" height="120px" visible="False"
="" width="176px">
<todaydaystyle backcolor="Transparent" forecolor="Red">
<weekenddaystyle backcolor="#FFC0C0" forecolor="#804040">



                       
                       
       
<asp:label id="Label9" runat="server" text="End Date:" width="104px"> 
<asp:textbox id="TextBox2" runat="server" width="112px"> 
<asp:imagebutton id="ImageButton2" runat="server" imageurl="~/Images/calendar.jpg"
="" width="24px"> 

<asp:calendar id="Calendar2" runat="server" height="120px" visible="False" width="176px">
<todaydaystyle backcolor="Transparent" forecolor="Red">
<weekenddaystyle backcolor="#FFC0C0" forecolor="#804040">

                       
                       
              
<asp:button id="btnOOk" runat="server" font-bold="True" forecolor="Black" text="OK"
="" width="56px">
   
<asp:button id="Button3" runat="server" font-bold="True" forecolor="Black" text="Cancel">
       
<asp:button id="Button1" runat="server" text="Button">


<asp:gridview id="ParentGridView" runat="server" style="z-index: 100; left: 27px; position: absolute;
top: 509px" autogeneratecolumns="False" backcolor="White" bordercolor="#336666" borderstyle="Double"
="" borderwidth="3px" cellpadding="3" gridlines="Horizontal" allowpaging="False" datakeynames="Userid" onrowdatabound="ParentGridView_rowDataBound">
<footerstyle backcolor="White" forecolor="#333333">
<rowstyle backcolor="White" forecolor="#333333">
<selectedrowstyle backcolor="#339966" font-bold="True" forecolor="White">
<pagerstyle backcolor="#336666" forecolor="White" horizontalalign="Center">
<headerstyle backcolor="#336666" font-bold="True" forecolor="White">
<columns>
<asp:templatefield headertext="Employee Name">
<itemtemplate>
<asp:label id="EmpName" runat="Server" text="<%# Bind("Userid") %>">



<asp:boundfield datafield="TotalTime" dataformatstring="{0:n}" headertext="TotalTime">

<asp:templatefield headertext="Weekly Report" insertvisible="False">
<itemtemplate>
<asp:gridview id="ChildGridView" runat="server" autogeneratecolumns="False">

<columns>
<asp:boundfield datafield="PDate" headertext="Date" htmlencode="False">
<asp:boundfield datafield="Time2" dataformatstring="{0:t}" headertext="TimeIn" htmlencode="False">
<asp:boundfield datafield="TIN" headertext="In" htmlencode="False">
<asp:boundfield datafield="Time1" dataformatstring="{0:t}" headertext="TimeOUT" htmlencode="False">

<asp:templatefield headertext="TOUT">
<itemtemplate>
<asp:label id="Label2" runat="server" text="<%# Bind("TOUT", "{0:t}") %>">

<footertemplate>
<asp:label id="Label7" text="Total:" font-bold="True" width="50" borderstyle="Solid"
="" borderwidth="0" style="padding:2px; margin-top:5px" runat="Server">

<asp:label id="Label4" text="OverTime:" font-bold="True" width="50" borderstyle="Solid"
="" borderwidth="0" style="padding:2px; margin-top:5px" runat="Server">

<asp:templatefield headertext="TotalTime">
<itemtemplate>
<asp:label id="Label3" text="<%# FormatNumber(Get_Time(Eval("TotalTime"))) %>" runat="Server">


<footertemplate>
<asp:label id="TotalTime" text="<%# FormatNumber(Get_Total_Time()) %>" width="80" runat="Server"
="" font-bold="True" borderstyle="Solid" borderwidth="1" bordercolor="#C0C0C0" style="padding:2px; margin-top:5px">

<asp:label id="Label5" text="<%# FormatNumber(Get_Over_Time()) %>" runat="Server">

<itemstyle horizontalalign="Right">
<footerstyle borderwidth="0px" font-bold="True" horizontalalign="Right">

















Shrihit
AnswerRe: Pass values in nested gridview Pin
ChrisKo17-Sep-07 10:58
ChrisKo17-Sep-07 10:58 
Questiongridview/datatable with grouped data Pin
sanjay_tutu17-Sep-07 8:09
sanjay_tutu17-Sep-07 8:09 
AnswerRe: gridview/datatable with grouped data Pin
ChrisKo17-Sep-07 10:56
ChrisKo17-Sep-07 10:56 
QuestionMembership.GetUser() fails in Modal dialog Pin
snir_ya17-Sep-07 7:13
snir_ya17-Sep-07 7:13 
AnswerRe: Membership.GetUser() fails in Modal dialog Pin
Saksida Bojan17-Sep-07 11:21
Saksida Bojan17-Sep-07 11:21 
GeneralRe: Membership.GetUser() fails in Modal dialog Pin
VenkataRamana.Gali17-Sep-07 19:56
VenkataRamana.Gali17-Sep-07 19:56 
QuestionUnable to re-enable a radio button if disabled server-side Pin
WSonck17-Sep-07 6:55
WSonck17-Sep-07 6:55 
AnswerRe: Unable to re-enable a radio button if disabled server-side Pin
ChrisKo17-Sep-07 10:52
ChrisKo17-Sep-07 10:52 
GeneralRe: Unable to re-enable a radio button if disabled server-side Pin
WSonck17-Sep-07 21:01
WSonck17-Sep-07 21:01 
QuestionMenu control flyouts don't appear where the should Pin
eggsovereasy17-Sep-07 6:12
eggsovereasy17-Sep-07 6:12 
QuestionGridView Row updating : e.NewValues is null Pin
ss.mmm17-Sep-07 5:20
ss.mmm17-Sep-07 5:20 
AnswerRe: GridView Row updating : e.NewValues is null Pin
DavidNohejl17-Sep-07 5:56
DavidNohejl17-Sep-07 5:56 
QuestionRe: GridView Row updating : e.NewValues is null Pin
ss.mmm17-Sep-07 11:05
ss.mmm17-Sep-07 11:05 
QuestionVS 2003 - Asp.Net Project Settings Pin
matthias s.17-Sep-07 4:55
matthias s.17-Sep-07 4:55 
AnswerRe: VS 2003 - Asp.Net Project Settings Pin
monu nair18-Sep-07 17:33
monu nair18-Sep-07 17:33 
GeneralRe: VS 2003 - Asp.Net Project Settings Pin
matthias s.19-Sep-07 4:58
matthias s.19-Sep-07 4:58 
QuestionStatic Method to get Data from DB? Pin
error140817-Sep-07 4:49
error140817-Sep-07 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.