Ask a Question related to ASP.NET Data Grid Control, Design and Development.
- leezard #1
System.ArgumentOutOfRangeException Specified argument was out of the range of valid values. Parameter name:
index
Exception Details: System.ArgumentOutOfRangeException: Specified argument
was out of the range of valid values. Parameter name: index
Below is my code:
Sub MyDataGrid_EditCommand(s As Object, e As DataGridCommandEventArgs )
MyDataGrid.EditItemIndex = e.Item.ItemIndex
BindData
End Sub
Sub MyDataGrid_Cancel(Source As Object, E As DataGridCommandEventArgs)
MyDataGrid.EditItemIndex = -1
BindData()
End Sub
Sub MyDataGrid_UpdateCommand(s As Object, e As DataGridCommandEventArgs )
Dim conn As SqlConnection
Dim MyCommand As SqlCommand
Dim strConn as string =
"server=localhost;trusted_connection=true;database =PTG"
Dim txtDate As textbox = E.Item.cells(2).Controls(0)
Dim txtMorning As textbox = E.Item.cells(3).Controls(0)
Dim txtAfternoon As textbox = E.Item.cells(4).Controls(0)
Dim txtNight As textbox = E.Item.cells(5).Controls(0)
Dim txtMin As textbox = E.Item.cells(6).Controls(0)
Dim txtMax As textbox = E.Item.cells(7).Controls(0)
Dim strUpdateStmt As String
strUpdateStmt =" UPDATE Weather SET" & _
" Date =@Date, morning =@morning, afternoon =@afternoon, night
=@night, min =@min, max =@max" & _
" WHERE wea_id = @wea_id "
conn = New SqlConnection(strConn)
MyCommand = New SqlCommand(strUpdateStmt, conn)
MyCommand.Parameters.Add(New SQLParameter("@Date", txtDate.text))
MyCommand.Parameters.Add(New SQLParameter("@morning",
txtMorning.text))
MyCommand.Parameters.Add(New SQLParameter("@afternoon",
txtAfternoon.text))
MyCommand.Parameters.Add(New SQLParameter("@night", txtNight.text))
MyCommand.Parameters.Add(New SQLParameter("@min", txtMin.text))
MyCommand.Parameters.Add(New SQLParameter("@max", txtMax.text))
MyCommand.Parameters.Add(New SQLParameter("@wea_id",
e.Item.Cells(1).Text ))
conn.Open()
MyCommand.ExecuteNonQuery()
MyDataGrid.EditItemIndex = -1
conn.close
BindData
End Sub
Sub Page_Load(Source as Object, E as EventArgs)
if not Page.IsPostBack then
BindData
end if
End Sub
Sub BindData()
Dim strConn as string =
"server=localhost;trusted_connection=true;database =PTG"
Dim sql as string = "Select wea_id, Date, morning, afternoon, night, min,
max from Weather"
Dim conn as New SQLConnection(strConn)
Dim objDR as SQLDataReader
Dim Cmd as New SQLCommand(sql, conn)
conn.Open()
objDR=Cmd.ExecuteReader(system.data.CommandBehavio r.CloseConnection)
MyDataGrid.DataSource = objDR
MyDataGrid.DataBind()
conn.close
End Sub
Thanks in advance.
leezard Guest
-
Some 'System Calls' was Capturing system call output value
On Friday, Nov 14, 2003, at 18:39 US/Pacific, Jerry Rocteur wrote: Wiggins is the one who deserves the point, since he was the one with the... -
System.Net.WebException occurred in system.web.services.dll - HTTP status 405: Method not allowed.
Hi, Have anyone ever encountered an exception error: The request failed with HTTP status 405: Method not allowed when trying to remotely invoke a... -
The type System.Web.UI.WebControls.TextBox in Assembly System.Web...error
I've been getting this error every since I installed InstallSqlState to handle my viewState Sessions. it only happens on 1 section of my asp.net... -
Method not found: System.Collections.Specialized.NameValueCollection System.Web.HttpRequest.get_QueryString().
I just recently started getting the above error on a page I am posting MULTIPART/FORM-DATA. We have SoftArtisans FileUp component and Filter... -
How to: Network XP system to system running 2000?
I have a desktop running XP. I have a laptop running 2000. They share an internet connection through a Linksys wireless router. My question... - leezard #2
Re: System.ArgumentOutOfRangeException I've figured it out.
thanks for viewing. :)
"leezard" <[email protected]> wrote in message
news:ODEgu%[email protected]..txtNight.text))> Specified argument was out of the range of valid values. Parameter name:
> index
> Exception Details: System.ArgumentOutOfRangeException: Specified argument
> was out of the range of valid values. Parameter name: index
> Below is my code:
>
> Sub MyDataGrid_EditCommand(s As Object, e As DataGridCommandEventArgs )
> MyDataGrid.EditItemIndex = e.Item.ItemIndex
> BindData
> End Sub
> Sub MyDataGrid_Cancel(Source As Object, E As DataGridCommandEventArgs)
> MyDataGrid.EditItemIndex = -1
> BindData()
> End Sub
>
> Sub MyDataGrid_UpdateCommand(s As Object, e As DataGridCommandEventArgs )
> Dim conn As SqlConnection
> Dim MyCommand As SqlCommand
> Dim strConn as string =
> "server=localhost;trusted_connection=true;database =PTG"
> Dim txtDate As textbox = E.Item.cells(2).Controls(0)
> Dim txtMorning As textbox = E.Item.cells(3).Controls(0)
> Dim txtAfternoon As textbox = E.Item.cells(4).Controls(0)
> Dim txtNight As textbox = E.Item.cells(5).Controls(0)
> Dim txtMin As textbox = E.Item.cells(6).Controls(0)
> Dim txtMax As textbox = E.Item.cells(7).Controls(0)
> Dim strUpdateStmt As String
>
> strUpdateStmt =" UPDATE Weather SET" & _
> " Date =@Date, morning =@morning, afternoon =@afternoon, night
> =@night, min =@min, max =@max" & _
> " WHERE wea_id = @wea_id "
> conn = New SqlConnection(strConn)
> MyCommand = New SqlCommand(strUpdateStmt, conn)
> MyCommand.Parameters.Add(New SQLParameter("@Date", txtDate.text))
> MyCommand.Parameters.Add(New SQLParameter("@morning",
> txtMorning.text))
> MyCommand.Parameters.Add(New SQLParameter("@afternoon",
> txtAfternoon.text))
> MyCommand.Parameters.Add(New SQLParameter("@night",> MyCommand.Parameters.Add(New SQLParameter("@min", txtMin.text))
> MyCommand.Parameters.Add(New SQLParameter("@max", txtMax.text))
> MyCommand.Parameters.Add(New SQLParameter("@wea_id",
> e.Item.Cells(1).Text ))
> conn.Open()
> MyCommand.ExecuteNonQuery()
> MyDataGrid.EditItemIndex = -1
> conn.close
> BindData
> End Sub
>
> Sub Page_Load(Source as Object, E as EventArgs)
> if not Page.IsPostBack then
> BindData
> end if
> End Sub
> Sub BindData()
> Dim strConn as string =
> "server=localhost;trusted_connection=true;database =PTG"
> Dim sql as string = "Select wea_id, Date, morning, afternoon, night, min,
> max from Weather"
> Dim conn as New SQLConnection(strConn)
> Dim objDR as SQLDataReader
> Dim Cmd as New SQLCommand(sql, conn)
> conn.Open()
> objDR=Cmd.ExecuteReader(system.data.CommandBehavio r.CloseConnection)
> MyDataGrid.DataSource = objDR
> MyDataGrid.DataBind()
> conn.close
> End Sub
>
> Thanks in advance.
>
>
leezard Guest




