mga kuya help po ulit pls...
gagawa po ako ng table ng mga employee sa CODE BEHIND... yun kasi ang approach na pinag aaralan ko ngayun. plus ayaw ko tlga masanay ng nag dadrag n drop ng mga control. As much as possible I am also avoiding writing anything on the HTML source because that will spoil my CODE-BEHIND training. so please don't reply suggesting a different approach, I just want to know whats wrong.
galing po kasi ako sa CLASSIC ASP and 2 months p lang ako nag aaral ng asp.net... I don't know kung maniniwala kayo saken pero tlgang hindi masyadong nkakatulong yung experience ko sa Classic. Maybe because lagi kong hinahanap yung substitute ng How to's ng .NET over the Classic.
anyway the my real problem as of this moment is I cant get the selectedItem.Value of a server-side Dropdownlist...
eto po ang ACTUAL code..
<%
@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="FM_Employee_Master.aspx.vb" Inherits="FM_Employee_Master" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<
div class="date_break"> File Maintenance - Employee Personal Information</div>
<div class="post" runat="server" id="Div_GridHolder" style="margin-left:auto; margin-right:auto">
<h1 style='text-align: left;' runat="server" id="H1_Title1"></h1><span class='post_body' style="width:100%">
<asp:Table ID="Emp_Grid" runat="server" Width="100%"></asp:Table></span>
</div>
</
asp:Content>
Partial Class FM_Employee_Master
Inherits System.Web.UI.PageProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim HeaderROW As TableRow = New TableRow
Dim HeaderCELL_ID As TableCell = New TableCellDim HeaderCELL_Name As TableCell = New TableCell
Dim HeaderCELL_Gender As TableCell = New TableCellDim HeaderCELL_Bday As TableCell = New TableCell
Dim HeaderCELL_EmpStat As TableCell = New TableCellDim HeaderCELL_BLANK As TableCell = New TableCell
Dim myConn As myConnections = New myConnections
Dim mySQL As String
Div_GridHolder.Style(
"width") = "90%"With H1_Title1
.InnerText =
"Employee List"
.Style(
"text-align") = "Center".Style("border") = 1
End WithWith HeaderROW
.Cells.Add(HeaderCELL_ID)
.Cells.Add(HeaderCELL_Name)
.Cells.Add(HeaderCELL_Gender)
.Cells.Add(HeaderCELL_Bday)
.Cells.Add(HeaderCELL_EmpStat)
.Cells.Add(HeaderCELL_BLANK)
End WithWith HeaderCELL_ID
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"
.Style(
"font-weight") = "bold"
.Style(
"text-decoration") = "Underline"
.BackColor = Drawing.Color.DarkSlateGray
.Text =
"I.D."
End WithWith HeaderCELL_Name
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"
.Style(
"font-weight") = "bold"
.Style(
"text-decoration") = "Underline"
.BackColor = Drawing.Color.DarkSlateGray
.Text =
"Name"
End WithWith HeaderCELL_Gender
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"
.Style(
"font-weight") = "bold"
.Style(
"text-decoration") = "Underline"
.BackColor = Drawing.Color.DarkSlateGray
.Text =
"Gender"
End WithWith HeaderCELL_Bday
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"
.Style(
"font-weight") = "bold"
.Style(
"text-decoration") = "Underline"
.BackColor = Drawing.Color.DarkSlateGray
.Text =
"Date of Birth"
End WithWith HeaderCELL_EmpStat
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"
.Style(
"font-weight") = "bold"
.Style(
"text-decoration") = "Underline"
.BackColor = Drawing.Color.DarkSlateGray
.Text =
"Employment Status"
End WithWith HeaderCELL_BLANK
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.BackColor = Drawing.Color.DarkSlateGray
End WithWith Emp_Grid
.Rows.Add(HeaderROW)
.CellSpacing = 0
.CellPadding = 0
myConn.Open()
mySQL =
"Select * from [Personal_Info]"Dim myCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(mySQL, myConn.Connection_Output)
Dim myDataReader As System.Data.SqlClient.SqlDataReader = myCommand.ExecuteReader()While myDataReader.Read()
Dim Body_Row As New TableRow
.Rows.Add(Body_Row)
Dim Body_Cell_ID As New TableCellDim Body_Cell_Name As New TableCell
Dim Body_Cell_Gender As New TableCellDim Body_Cell_BDay As New TableCell
Dim Body_Cell_Emp_Stat As New TableCellDim Body_Cell_Action As New TableCell
Body_Row.Cells.Add(Body_Cell_ID)
Body_Row.Cells.Add(Body_Cell_Name)
Body_Row.Cells.Add(Body_Cell_Gender)
Body_Row.Cells.Add(Body_Cell_BDay)
Body_Row.Cells.Add(Body_Cell_Emp_Stat)
Body_Row.Cells.Add(Body_Cell_Action)
With Body_Cell_ID
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center".Text = myDataReader("Emp_ID")
End WithWith Body_Cell_Name
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"Body_Cell_Name.Text = myDataReader("Name_Last") & ", " & myDataReader("Name_First") & " " & myDataReader("Name_Middle")
End WithWith Body_Cell_Gender
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"
Dim strGender As String
If myDataReader("Gender") Then
strGender =
"Male"
Else
strGender =
"Female"
End If
Body_Cell_Gender.Text = strGender
End WithWith Body_Cell_BDay
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center".Text = FormatDateTime(myDataReader("Birthdate"), DateFormat.LongDate)
End WithWith Body_Cell_Emp_Stat
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"Dim myConn2 As myConnections = New myConnections
Dim mySQL2 As String = "Select employment_Status.title from employment_Status employment_Status, Current_Employment_Stat Current_Employment_Stat WHERE (Current_Employment_Stat.employmentstatus_ID = employment_Status.employmentstatus_ID) AND Current_Employment_Stat.isCurrent = 1 AND Current_Employment_Stat.Emp_ID = @Emp_Id"
myConn2.Open()
Dim myCommand2 As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(mySQL2, myConn2.Connection_Output)
myCommand2.Parameters.Add(
New System.Data.SqlClient.SqlParameter("@Emp_Id", myDataReader("Emp_ID")))Dim myDataReader2 As System.Data.SqlClient.SqlDataReader = myCommand2.ExecuteReader()While myDataReader2.Read()
.Text = myDataReader2(
"title")
End While
myConn2.Close()
End WithWith Body_Cell_Action
Dim i As Integer = myDataReader("Emp_ID")Dim DrpLst_Action(i) As System.Web.UI.WebControls.DropDownList
DrpLst_Action(i) =
New System.Web.UI.WebControls.DropDownListWith DrpLst_Action(i)
.ID =
"ID_" & i.Attributes.Add("runat", "server")
.Items.Add(
New ListItem("--Select--", 0)).Items.Add(New ListItem("View/Edit personal info", 1))
.Items(1).Value = 1
.Items.Add(New ListItem("View/Edit employment record", 2))
.Items.Add(
New ListItem("View time-in/time-out logs", 3)).Attributes.Add("onchange", "window.location.href='FM_Employee_Master.aspx?actionSelected=" & DrpLst_Action(i).SelectedItem.Value & "'") '<-------THis is the PROBLEM AREA
End With
.BorderWidth = 1
.BorderColor = Drawing.Color.Gray
.Style(
"text-align") = "center"
.Controls.Add(DrpLst_Action(i))
End With
End While
myConn.Close()
End With
End IfEnd Sub
End
Class
wala pong problem sa pag generate ng table at pag retrieve ng value sa dbase. ang problema tlga e yung dropdownlist value.... nde ko makuha..
onchange ng dropdownlist I tried to call the page again and pass the value of the dropdownlist sa querystring kaya lang laging yung unang item lang ang nakukuha nya.
salamat po