none
我從資料庫比對出最大值後減除最大值的資料後,用dorpdownlist 列出。選擇後存入,但值為空的... asp.net(VB)-2010 RRS feed

  • 問題

  • 我從資料庫比對出最大值後減除最大值的資料後
    再利用 dorpdownlist 列出後

    選擇所要的日期後存入

    值為空的

    存入時為空值

    有無解決方法 或寫錯了

    請大人們指教

    非常謝謝

    以下是程式片段 

    Protected Sub GridView8_DataBound(sender As Object, e As System.EventArgs) Handles GridView8.DataBound

     ads3.ConnectionString = conn3
     ads3.SelectCommand = "select D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, (select max(Val) from (select D1 as Val union all select D2 union all select D3 union all select D4 union all select D5 union all select D6 union all select D7 union all select D8 union all select D9 union all select D10) as Val) as MaxVal from LinkClassDayCK WHERE Years = '" & Me.DropDownList4.Text & "' and Months = '" & Me.DropDownList5.Text & "' and ClassIndex = '" & Me.HiddenField1.Value & "'"

    dv3 = ads3.Select(New DataSourceSelectArguments)

       If dv3.Item(0).Item("MaxVal") Is DBNull.Value Then

                Me.DropDownList9.Items.Clear()
                Dim day As Integer = DateTime.Now.AddDays(1).Day 
                For i As Integer = 1 To 31   
                    day += 1
                    Dim obj As New ListItem()
                    obj.Text = day.ToString() - 2 & "日"
                    obj.Value = day.ToString() - 2 & "日"

                    DropDownList9.Items.Add(obj)
                Next
                DropDownList9.SelectedValue = day.ToString() - 1 & "日"
            Else
                Me.DropDownList9.Items.Clear()
                Dim lastDay As DateTime = dv3.Item(0).Item("MaxVal").ToString().Trim
                Dim lastDayInt As Integer = lastDay.ToString("dd") + 1

                Dim day As Integer = DateTime.Now.AddDays(lastDayInt).Day  
                For i As Integer = 1 To 31 - lastDayInt + 1   
                    day += 1
                    Dim obj As New ListItem()
                    obj.Text = day.ToString() - 2 & "日"
                    obj.Value = day.ToString() - 2 & "日"
                    DropDownList9.Items.Add(obj)
                Next
                DropDownList9.SelectedValue = day.ToString() - 3 & "日"

            End If

       End Sub
    • 已移動 Bill ChungMVP 2014年1月2日 上午 02:46 ASP.NET 開發
    2014年1月2日 上午 02:11

解答

所有回覆