Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2004, 04:26 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default not able to get the value of the dropdownlist

HI in the following code I am not able to get the value for the dropdownlist value. any body can help me out .

Function GetLastUpdated(strTableName)
                       Dim strSQL1 As String
                       Dim strUpdated as string


                              strSQL1 = "select to_char((max(ATTEND_DATE)),'mm/dd/yyyy')dt from ALT_ED_ATTENDANCE"

                                  Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;;Data Source=;Persist Security Info=true")
                                  Dim myCommand As OleDbCommand = New OleDbCommand(strSQL1, myConnection)


                                  Try
                                      myConnection.Open()
                                      Dim result As OleDbDataReader = myCommand.ExecuteReader()

                                      result.Read()
                                      strUpdated = result("dt")

                                        result.Close()


                                  Catch err as Exception
                                      strUpdated="Error getting date."
                                  Finally

                                  If (Not myConnection is Nothing) Then
                                       myConnection.Close()
                                  End If

                                  end try


                      return strUpdated


                  End Function

         Function GetDataSource()
                      Dim dt As New DataTable()
                      Dim dr As DataRow
                      Dim defult as String

                       Dim strSQL2 as String

                     If Not IsPostBack Then




                              strSQL2 = "select descr Reason, absence_cd code from absence_cd"


                     end if
                      Dim myConnection2 As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password=hs;Pe rsist Security Info=true")
                      Dim myCommand As OleDbCommand = New OleDbCommand(strSQL2, myConnection2)

                        myConnection2.Open ()

                        Dim result As OleDbDataReader = myCommand.ExecuteReader

                        dt.Columns.Add(New DataColumn("Code", GetType(String)))
                        dt.Columns.Add(New DataColumn("Reason", GetType(String)))




                        Do While result.Read()

                                  dr = dt.NewRow()

                                  dr(0) = result("code")
                                  dr(1) = result("Reason")
                                   dt.Rows.Add(dr)
                         Loop

                         result.Close()

                         myConnection2.Close ()

                          Dim dv As New DataView(dt)
                          Return dv

              End Function

              Protected strCourseCode As String


              Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


                     Dim strLastUpdated As String

                    Dim strSQL As String


                    strSQL= "select a.attend_date, a.permnum,a.lastname || ', ' || firstname student_name, 'Taft High School ' alternate_schoolnum, a.sending_schoolnum,asch.name scn from asch,alt_ed_attendance a ,(select to_char((max(ATTEND_DATE)),'mm/dd/yyyy') max_dt from alt_ed_attendance) b where asch.schoolnum = a.sending_schoolnum and a.alternate_schoolnum=410 and to_char((a.ATTEND_DATE),'mm/dd/yyyy')= max_dt"




                 Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;;Persist Security Info=true")

                  Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                              Try
                                  myConnection.Open()
                                  Dim result As OleDbDataReader = myCommand2.ExecuteReader()

                                  MyList.DataSource = result
                                  MyList.DataBind()


                                  MyList.Columns(1).ItemStyle.HorizontalAlign=Horizo ntalAlign.left
                                     MyList.Columns(2).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                                     MyList.Columns(3).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                                     MyList.Columns(4).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center

                                  result.Close()

                             Catch err as Exception


                                  end try

                             strLastUpdated = GetLastUpdated("LOAD alt_ed_attendance")

                                  lblUpdated.Text = "DATE: " & strLastUpdated



                              If (Not myConnection is Nothing) Then

                                   myConnection.Close()

                              End If



           Dim myConnection3 As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;;Persist Security Info=true")
                                  Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection3)


                                  myConnection3.Open ()





              end Sub


              Sub reason_SelectedIndexChanged(sender As Object, e As EventArgs)

               Dim strSQLreason As String


                    strSQLreason= "select absence_cd,descr,type from from absence_cd"




                 Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;;Persist Security Info=true")

                  Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQLreason, myConnection)
                              Try
                                  myConnection.Open()

                              catch

                              end try
              End Sub
              '

         Sub DataGrid1_SelectedIndexChanged(sender As Object, e As EventArgs)

         End Sub
    '<asp:DropDownList id="txtReason" runat="server" width="150"></asp:DropDownList>

</script>

<html>
<head>
</head>
<body bottommargin="0" bgcolor="#fffff8" leftmargin="0" topmargin="0" scroll="yes" rightmargin="0" marginheight="0" marginwidth="0">
    <p align="center">
        <img height="77" src="cps.gif" width="420" align="center" />
    </p>
    <p>
        <br />
        <b>Alternate Education Location: </b>
    </p>
    <b>
    <p>
        <asp:Label class="Normal" id="lblUpdated" visible="true" align="right" runat="Server">Label</asp:Label>
    </p>
    <p>
    </p>
    </b>
    <table height="100%" cellspacing="0" cellpadding="0" width="800" align="center">
        <tbody>
            <form runat="server">
                <tr valign="top">
                    <td width="1500">

                        <asp:DataGrid id="MyList" runat="server" Font-Names="Verdana" GridLines="BOTH" AutoGenerateColumns="false" AlternatingItemStyle-CssClass="CartListItemAlt" ItemStyle-CssClass="CartListItem" FooterStyle-CssClass="cartlistfooter" HeaderStyle-CssClass="CartListHead" Font-Size="8pt" Font-Name="Verdana" cellspacing="0" cellpadding="4" BorderColor="black" width="100%" HorizontalAlign="Center">
                            <FooterStyle cssclass="cartlistfooter"></FooterStyle>
                            <HeaderStyle font-bold="True" cssclass="CartListHead" backcolor="#80FFFF" horizontalalign="Center"></HeaderStyle>
                            <AlternatingItemStyle cssclass="CartListItemAlt"></AlternatingItemStyle>
                            <ItemStyle font-bold="False" cssclass="CartListItem"></ItemStyle>
                            <Columns>
                                <asp:BoundColumn Visible="False" DataField="attend_date" HeaderText="Date"></asp:BoundColumn>
                                <asp:BoundColumn DataField="permnum" HeaderText="StudentID"></asp:BoundColumn>
                                <asp:BoundColumn DataField="student_name" HeaderText="Student Name"></asp:BoundColumn>
                                <asp:BoundColumn DataField="scn" HeaderText="Current School"></asp:BoundColumn>
                                <asp:TemplateColumn Headertext="Reason">
                                    <itemTemplate>
                                        <asp:DropDownList id="txtReason" runat="server" width="150" dataTextField="Reason" DataValueField="code" datasource='<%#GetDataSource()%>' ></asp:DropDownList>
                                    </itemTemplate>
                                </asp:TemplateColumn>
                            </Columns>
                        </asp:DataGrid>
                        <div align="center">
                        </div>
                        <div align="center">
                        </div>
                        <div class="Submit" id="butUpdate" title="Save" align="center">
                            <asp:Button id="Button1" runat="server" BorderColor="#00C000" BackColor="#004000" ForeColor="White" Text="Save"></asp:Button>
                        </div>
                        </td>
                </tr>
            </form>
        </tbody>
    </table>
if I want to get the value with the strSQL= "UPDATE alt_ed_attendance SET attend_rsn= "'& txtReason.SelectedItem.Value &'""
I am not able to get the value of the selected filed in the dropdown list.
thanks


Aashish Shah
__________________
Aashish Shah
 
Old February 18th, 2004, 10:40 AM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Aashish,
I think I see the problem. Why it's a problem, I don't really know. I'll try not to talk about things I don't understand:D

You're trying to access something from the datagrid as if it were part of a form. Which it is...but its part of a datagrid, which is part of a form.

One thing I am unsure of; how is this going to be used? Is there going to be only one person at a time? By this I mean, is a user going to log on and change this or is this going to be part of a listing of students and someone else will go in and make this change?

Regardless of your answer to the above questions, the easiest solution would be to put this into an editable datagrid and make the change one item at a time. If this idea works for you and you need to know how to do it, please let me know. It is possible to make datagrid items readonly. With this in mind, you could make everything readonly except for the dropdownlist.

Ok, with that said, you can access items from the datagrid, it is just a bit more complicated. I had to do this just last week actually, only I was writing to the dg. It should be possible to do the opposite.

Here's what I did - using a recursive function (a function that calls itself) I found in Stephen Walther's ASP.NET UNLEASHED, 2nd Ed. (another book I highly recommend - it's pricey, but you should be able to get a student discount, ay?).

Code:
        
'this is the call of the function. dgUsers is the name of my datagrid.
'I called it with a click event.

    disControls(dgUsers)

'this is the recursive function. It loops through the control that
'is fed to it, in this case dgUsers, and then finds all of the child
'controls, if any, of all those controls. It will find any and every
'item in the dgUsers control. If you give an item an id, as you have
'done with your dropdownlist, you should be able to find it.

    Sub disControls(ByVal s As Object)
        Dim ctl As Control
        For Each ctl In s.controls
            displaycontrolinfo(ctl)
            disControls(ctl)
        Next
    End Sub

'this is the function that actually returns information about the
'specified item. As you can see, I am writing from the dropdownlist,
'dblstDept, to the field called 'deptSecurity.' Theoretically, you
'should be able to get the value of this field by writing s.text or
'something like that.

    Sub displaycontrolinfo(ByVal s As Object)
        If s.id = "deptSecurity" Then
            If dblstDept.SelectedItem.Value = "ALL" Then
                s.text = dblstDept.SelectedItem.Value
            ElseIf dblstDept.SelectedItem.Value = "Clear" Then
                s.text = ""
            Else
                If s.text = "" Then
                    s.text = dblstDept.SelectedItem.Value
                ElseIf InStr(s.text, dblstDept.SelectedItem.Value) < 1 Then
                    s.text &= "," & dblstDept.SelectedItem.Value
                End If
            End If
        End If
    End Sub
Let me know if this works. I'll be out for a bit, but will try to check the list later today.

mark

 
Old February 18th, 2004, 12:24 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it is not still giving me the same error that "txtReason" is not define.


Aashish Shah
 
Old February 18th, 2004, 12:41 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Aashish,
You're not trying to find txtReason.text, you're trying to find a control with the id txtReason. Call the function like this:
Code:
     disControls(nameOfYourDataGrid)

'change the displaycontrolinfo function to look like this:

     Sub displaycontrolinfo(ByVal s As Object)
        If s.id = "txtReason" Then
             viewState("reason") = s.text
             'you can use viewstate, cookies, or whatever
        End If
    End Sub
Of course, I am not promising this will work, just give it a shot.
mark


 
Old February 18th, 2004, 12:55 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can i send you the entire code of the page I am so confuse what to do and what not b'cos since yesterday I am doing this and whole day and night I was with that so I my mind is not working and I am so frustrated what to do I am not able to find the direction ..
this will be grate help from you mark ./..
thanks


Aashish Shah
 
Old February 18th, 2004, 01:16 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sure, you can send it. Why don't you just post it here? Then, go get some sleep. It sounds like you have moved into negative productivity...
mark

 
Old February 18th, 2004, 01:25 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks....
you get right!!!! I moved into negative thinking.......
I have send you an email to .
Here is the code for entire page.

------------------------------------------------------------------------------------

<%@ Page Language="VB" Debug="True" %>
<%@ import Namespace="System.Configuration" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Collections" %>
<script runat="server">

    Function GetLastUpdated(strTableName)
                          Dim strSQL1 As String
                          Dim strUpdated as string


                                 strSQL1 = "select to_char((max(ATTEND_DATE)),'mm/dd/yyyy')dt from ALT_ED_ATTENDANCE"

                                     Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;Password="";User ID=MAG_USER;Data Source=Local;Persist Security Info=true")
                                     Dim myCommand As OleDbCommand = New OleDbCommand(strSQL1, myConnection)


                                     Try
                                         myConnection.Open()
                                         Dim result As OleDbDataReader = myCommand.ExecuteReader()

                                         result.Read()
                                         strUpdated = result("dt")

                                           result.Close()


                                     Catch err as Exception
                                         strUpdated="Error getting date."
                                     Finally

                                     If (Not myConnection is Nothing) Then
                                          myConnection.Close()
                                     End If

                                     end try


                         return strUpdated


                     End Function



                     Sub disControls(ByVal s As Object)

                     Dim ctl As Control
                     For Each ctl In s.controls
                        displaycontrolinfo(ctl)
                        disControls(ctl)
                     Next

                     End Sub


                     Sub displaycontrolinfo(ByVal s As Object)
                        If s.id = "txtReason" Then
                         viewState("reason") = s.text

                        End If
                     End Sub



                 Sub submit_Button(ByVal sender As Object, ByVal e As ImageClickEventArgs)



                Dim strSQL


                 strSQL= "UPDATE alt_ed_attendance SET attend_rsn='" s.id &"' where permnum="1213456" "


                   Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password="";Us er ID=mag_user;Data Source=local;Persist Security Info=true")
                   Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                   Dim result As Integer

                   Try
                       myConnection.Open()
                       result = myCommand.ExecuteNonQuery


                   Catch err as Exception

                   Finally
                     If (Not myConnection is Nothing) Then

                        myConnection.Close()
                     End If
                   End Try


       end Sub



            Function GetDataSource()
                           Dim dt As New DataTable()
                           Dim dr As DataRow
                           Dim defult as String

                           Dim strSQL2 as String

                       If Not IsPostBack Then




                           strSQL2 = "select descr Reason, absence_cd code from absence_cd"


                       end if
                          Dim myConnection2 As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password="";Us er ID=dwhs;Data Source=Local;Persist Security Info=true")
                          Dim myCommand As OleDbCommand = New OleDbCommand(strSQL2, myConnection2)

                           myConnection2.Open ()

                           Dim result As OleDbDataReader = myCommand.ExecuteReader

                           dt.Columns.Add(New DataColumn("Code", GetType(String)))
                           dt.Columns.Add(New DataColumn("Reason", GetType(String)))




                           dr = dt.newrow()
                           dr(0) = "pres"
                           dr(1) = "Present"
                           dt.rows.add(dr)


                           Do While result.Read()


                           dr = dt.NewRow()
                           dr(0) = result("code")
                           dr(1) = result("Reason")
                           dt.Rows.Add(dr)

                           Loop

                           result.Close()

                           myConnection2.Close ()

                           Dim dv As New DataView(dt)
                           Return dv

                 End Function




                 Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


                        Dim strLastUpdated As String
                        Dim strSQL As String


                       strSQL= "select a.attend_date, a.permnum,a.lastname || ', ' || firstname student_name, 'Taft High School ' alternate_schoolnum, a.sending_schoolnum,asch.name scn from asch,alt_ed_attendance a ,(select to_char((max(ATTEND_DATE)),'mm/dd/yyyy') max_dt from alt_ed_attendance) b where asch.schoolnum = a.sending_schoolnum and a.alternate_schoolnum=410 and to_char((a.ATTEND_DATE),'mm/dd/yyyy')= max_dt"




                       Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;Password="";User ID=mag_user;Data Source=Local;Persist Security Info=true")
                       Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                       Try
                           myConnection.Open()
                           Dim result As OleDbDataReader = myCommand2.ExecuteReader()

                              MyList.DataSource = result
                              MyList.DataBind()


                              MyList.Columns(1).ItemStyle.HorizontalAlign=Horizo ntalAlign.left
                              MyList.Columns(2).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                              MyList.Columns(3).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                              MyList.Columns(4).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center

                        result.Close()

                        Catch err as Exception


                       End try

                        strLastUpdated = GetLastUpdated("LOAD alt_ed_attendance")

                        lblUpdated.Text = "DATE: " & strLastUpdated



                        If (Not myConnection is Nothing) Then

                        myConnection.Close()

                        End If



                     End Sub


            Sub reason_SelectedIndexChanged(sender As Object, e As EventArgs)

                  Dim strSQLreason As String
                  strSQLreason= "select absence_cd,descr,type from from absence_cd"




                  Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;Password="";User ID=dhws;Data Source=Local;Persist Security Info=true")
                  Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQLreason, myConnection)
                  Try
                  myConnection.Open()

                  catch

                  End try
            End Sub

</script>

<html>
<head>
    <title>Attendance Data@ Taft High School</title>
</head>
<body bottommargin="0" bgcolor="#fffff8" leftmargin="0" topmargin="0" scroll="yes" rightmargin="0" marginwidth="0" marginheight="0">
    <p align="center">
        <img height="77" src="cps.gif" width="420" align="center" />
    </p>
    <p>
        <br />
        <b>Alternate Education Location: Taft High School</b>
    </p>
    <b>
    <p>
        <asp:Label class="Normal" id="lblUpdated" runat="Server" align="right" visible="true">Label</asp:Label>
    </p>
    <p>
    </p>
    </b>
    <table height="100%" cellspacing="0" cellpadding="0" width="800" align="center">
        <tbody>
            <tr id="trn" valign="top">
                <td id="re" width="1500">

                    <form id="fmreason" name="fmrenem" runat="server">
                        <asp:DataGrid id="MyList" runat="server" HorizontalAlign="Center" width="100%" BorderColor="black" cellpadding="4" cellspacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-CssClass="CartListHead" FooterStyle-CssClass="cartlistfooter" ItemStyle-CssClass="CartListItem" AlternatingItemStyle-CssClass="CartListItemAlt" AutoGenerateColumns="false" GridLines="BOTH" Font-Names="Verdana">
                            <FooterStyle cssclass="cartlistfooter"></FooterStyle>
                            <HeaderStyle font-bold="True" cssclass="CartListHead" backcolor="#80FFFF" horizontalalign="Center"></HeaderStyle>
                            <AlternatingItemStyle cssclass="CartListItemAlt"></AlternatingItemStyle>
                            <ItemStyle font-bold="False" cssclass="CartListItem"></ItemStyle>
                            <Columns >
                                <asp:BoundColumn Visible="False" DataField="attend_date" HeaderText="Date"></asp:BoundColumn>
                                <asp:BoundColumn DataField="permnum" HeaderText="StudentID" ></asp:BoundColumn>
                                <asp:BoundColumn DataField="student_name" HeaderText="Student Name" ></asp:BoundColumn>
                                <asp:BoundColumn DataField="scn" HeaderText="Current School"></asp:BoundColumn>
                                <asp:TemplateColumn Headertext="Reason">
                                    <ItemTemplate >
                                        <asp:DropDownList id="txtReason" runat="server" width="150" dataTextField="Reason" DataValueField="code" datasource='<%#GetDataSource()%>' ></asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                            </Columns>
                        </asp:DataGrid>
                        <center>
                            <asp:ImageButton id="submit" onclick="submit_Button" runat="server" ImageUrl="images/submit.gif"></asp:ImageButton>
                        </center>
                    </form>
                </td>
            </tr>
        </tbody>
    </table>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
</body>
</html>


Aashish Shah
 
Old February 18th, 2004, 01:26 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you very much mark!!!!!!!!!!!!!
I dont know where I am driving my self in the development.. I am so frustrated today!!!!!!...
Please help me out ...
thanks
aashish

Aashish Shah
 
Old February 18th, 2004, 01:46 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this: in your sub 'submit_Button,' call the function 'disControls.' Then write viewState("reason") into your sqlstring. Like this:
Code:
Sub submit_Button(ByVal sender As Object, ByVal e As ImageClickEventArgs)

                disControls(nameofYourDataGrid)
                Dim strSQL
                strSQL= "UPDATE alt_ed_attendance SET attend_rsn='" & viewState("reason") &"' where permnum="1213456" "
                Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password="";User ID=mag_user;Data Source=local;Persist Security Info=true")
                Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                   Dim result As Integer

                   Try
                       myConnection.Open()
                       result = myCommand.ExecuteNonQuery


                   Catch err as Exception

                   Finally
                     If (Not myConnection is Nothing) Then

                        myConnection.Close()
                     End If
                   End Try
       end Sub
I don't know how much you have used 'viewstate,' but the name you use is case-sensitive. For example, viewstate("reason") is not the same as viewstate("Reason"). Let me know what happens.
mark

 
Old February 18th, 2004, 02:18 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<%@ Page Language="VB" Debug="True" %>
<%@ import Namespace="System.Configuration" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Collections" %>
<script runat="server">

    Function GetLastUpdated(strTableName)
                          Dim strSQL1 As String
                          Dim strUpdated as string


                                 strSQL1 = "select to_char((max(ATTEND_DATE)),'mm/dd/yyyy')dt from ALT_ED_ATTENDANCE"

                                     Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;Password="";User ID=MAG_USER;Data Source=Local;Persist Security Info=true")
                                     Dim myCommand As OleDbCommand = New OleDbCommand(strSQL1, myConnection)


                                     Try
                                         myConnection.Open()
                                         Dim result As OleDbDataReader = myCommand.ExecuteReader()

                                         result.Read()
                                         strUpdated = result("dt")

                                           result.Close()


                                     Catch err as Exception
                                         strUpdated="Error getting date."
                                     Finally

                                     If (Not myConnection is Nothing) Then
                                          myConnection.Close()
                                     End If

                                     end try


                         return strUpdated


                     End Function



                     Sub disControls(ByVal s As Object)

                     Dim ctl As Control
                     For Each ctl In s.controls
                        displaycontrolinfo(ctl)
                        disControls(ctl)
                     Next

                     End Sub


                     Sub displaycontrolinfo(ByVal s As Object)
                        If s.id = "txtReason" Then
                         viewState("reason") = s.txtReason

                        End If
                     End Sub



                 Sub submit_Button(ByVal sender As Object, ByVal e As ImageClickEventArgs)

                disControls(MyList)
                Dim strSQL
                strSQL= "UPDATE alt_ed_attendance SET attend_rsn='" & viewState("reason") &"' where permnum="1213456" "
                Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password="";Us er ID=mag_user;Data Source=local;Persist Security Info=true")
                Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                   Dim result As Integer

                   Try
                       myConnection.Open()
                       result = myCommand.ExecuteNonQuery


                   Catch err as Exception

                   Finally
                     If (Not myConnection is Nothing) Then

                        myConnection.Close()
                     End If
                   End Try
       end Sub

            Function GetDataSource()
                           Dim dt As New DataTable()
                           Dim dr As DataRow
                           Dim defult as String

                           Dim strSQL2 as String

                       If Not IsPostBack Then




                           strSQL2 = "select descr Reason, absence_cd code from absence_cd"


                       end if
                          Dim myConnection2 As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA.1;Password="";Us er ID=dwhs;Data Source=Local;Persist Security Info=true")
                          Dim myCommand As OleDbCommand = New OleDbCommand(strSQL2, myConnection2)

                           myConnection2.Open ()

                           Dim result As OleDbDataReader = myCommand.ExecuteReader

                           dt.Columns.Add(New DataColumn("Code", GetType(String)))
                           dt.Columns.Add(New DataColumn("Reason", GetType(String)))




                           dr = dt.newrow()
                           dr(0) = "pres"
                           dr(1) = "Present"
                           dt.rows.add(dr)


                           Do While result.Read()


                           dr = dt.NewRow()
                           dr(0) = result("code")
                           dr(1) = result("Reason")
                           dt.Rows.Add(dr)

                           Loop

                           result.Close()

                           myConnection2.Close ()

                           Dim dv As New DataView(dt)
                           Return dv

                 End Function




                 Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


                        Dim strLastUpdated As String
                        Dim strSQL As String


                       strSQL= "select a.attend_date, a.permnum,a.lastname || ', ' || firstname student_name, 'Taft High School ' alternate_schoolnum, a.sending_schoolnum,asch.name scn from asch,alt_ed_attendance a ,(select to_char((max(ATTEND_DATE)),'mm/dd/yyyy') max_dt from alt_ed_attendance) b where asch.schoolnum = a.sending_schoolnum and a.alternate_schoolnum=410 and to_char((a.ATTEND_DATE),'mm/dd/yyyy')= max_dt"




                       Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;Password="";User ID=mag_user;Data Source=Local;Persist Security Info=true")
                       Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQL, myConnection)
                       Try
                           myConnection.Open()
                           Dim result As OleDbDataReader = myCommand2.ExecuteReader()

                              MyList.DataSource = result
                              MyList.DataBind()


                              MyList.Columns(1).ItemStyle.HorizontalAlign=Horizo ntalAlign.left
                              MyList.Columns(2).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                              MyList.Columns(3).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center
                              MyList.Columns(4).ItemStyle.HorizontalAlign=Horizo ntalAlign.Center

                        result.Close()

                        Catch err as Exception


                       End try

                        strLastUpdated = GetLastUpdated("LOAD alt_ed_attendance")

                        lblUpdated.Text = "DATE: " & strLastUpdated



                        If (Not myConnection is Nothing) Then

                        myConnection.Close()

                        End If



                     End Sub


            Sub reason_SelectedIndexChanged(sender As Object, e As EventArgs)

                  Dim strSQLreason As String
                  strSQLreason= "select absence_cd,descr,type from from absence_cd"




                  Dim myConnection As OleDbConnection = New OleDbConnection("PROVIDER=MSDAORA;Password="";User ID=dhws;Data Source=Local;Persist Security Info=true")
                  Dim myCommand2 As OleDbCommand = New OleDbCommand(strSQLreason, myConnection)
                  Try
                  myConnection.Open()

                  catch

                  End try
            End Sub

</script>

<html>
<head>
    <title>Attendance Data@ Taft High School</title>
</head>
<body bottommargin="0" bgcolor="#fffff8" leftmargin="0" topmargin="0" scroll="yes" rightmargin="0" marginwidth="0" marginheight="0">
    <p align="center">
        <img height="77" src="cps.gif" width="420" align="center" />
    </p>
    <p>
        <br />
        <b>Alternate Education Location: Taft High School</b>
    </p>
    <b>
    <p>
        <asp:Label class="Normal" id="lblUpdated" runat="Server" align="right" visible="true">Label</asp:Label>
    </p>
    <p>
    </p>
    </b>
    <table height="100%" cellspacing="0" cellpadding="0" width="800" align="center">
        <tbody>
            <tr id="trn" valign="top">
                <td id="re" width="1500">

                    <form id="fmreason" name="fmrenem" runat="server">
                        <asp:DataGrid id="MyList" runat="server" HorizontalAlign="Center" width="100%" BorderColor="black" cellpadding="4" cellspacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-CssClass="CartListHead" FooterStyle-CssClass="cartlistfooter" ItemStyle-CssClass="CartListItem" AlternatingItemStyle-CssClass="CartListItemAlt" AutoGenerateColumns="false" GridLines="BOTH" Font-Names="Verdana">
                            <FooterStyle cssclass="cartlistfooter"></FooterStyle>
                            <HeaderStyle font-bold="True" cssclass="CartListHead" backcolor="#80FFFF" horizontalalign="Center"></HeaderStyle>
                            <AlternatingItemStyle cssclass="CartListItemAlt"></AlternatingItemStyle>
                            <ItemStyle font-bold="False" cssclass="CartListItem"></ItemStyle>
                            <Columns >
                                <asp:BoundColumn Visible="False" DataField="attend_date" HeaderText="Date"></asp:BoundColumn>
                                <asp:BoundColumn DataField="permnum" HeaderText="StudentID" ></asp:BoundColumn>
                                <asp:BoundColumn DataField="student_name" HeaderText="Student Name" ></asp:BoundColumn>
                                <asp:BoundColumn DataField="scn" HeaderText="Current School"></asp:BoundColumn>
                                <asp:TemplateColumn Headertext="Reason">
                                    <ItemTemplate >
                                        <asp:DropDownList id="txtReason" runat="server" width="150" dataTextField="Reason" DataValueField="code" datasource='<%#GetDataSource()%>' ></asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                            </Columns>
                        </asp:DataGrid>
                        <center>
                            <asp:ImageButton id="submit" onclick="submit_Button" runat="server" ImageUrl="images/submit.gif"></asp:ImageButton>
                        </center>
                    </form>
                </td>
            </tr>
        </tbody>
    </table>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
    <p>
    </p>
</body>
</html>



this gives me the error like this ....
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMemberException: Public member 'txtReason' on type 'DropDownList' not found.

Source Error:


Line 59: Sub displaycontrolinfo(ByVal s As Object)
Line 60: If s.id = "txtReason" Then
Line 61: viewState("reason") = s.txtReason
Line 62:
Line 63: End If


Source File: I:\SIS Web Sites\Alternate Edu\data_taft1.aspx Line: 61

thanks mark...
But right now I am not able to think of any thing else.. just getting confuse..
Please bare with me...
thanks
aashish


Aashish Shah





Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist sumith ASP.NET 1.0 and 1.1 Professional 1 February 23rd, 2007 09:11 AM
DropdownList Venkatesan ASP.NET 1.0 and 1.1 Basics 1 December 11th, 2006 11:03 AM
how to get value from dropdownlist vandat ASP.NET 1.0 and 1.1 Basics 3 November 28th, 2005 12:47 AM
DropDownList chiraagb VS.NET 2002/2003 5 June 15th, 2004 03:12 AM
dropdownlist msrnivas .NET Web Services 0 March 4th, 2004 11:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.