radgrid
-
hay guys i am still beginner in asp.net whn i tryed this code i got the "index out the bound of array" so plzz help me in this error Dim MyConn As New SqlConnection("Data Source=ASMAA-PC;Initial Catalog=LogFinity;Integrated Security=True") Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load 'Dim conn As String = "Data Source=ASMAA-PC;Initial Catalog=LogFinity;Integrated Security=True" Dim MyAdapter As New SqlDataAdapter MyConn.Open() MyAdapter.SelectCommand = New SqlCommand("Select * from RecCalls", MyConn) Try MyAdapter.Fill(CallDS) Finally MyConn.Close() End Try End Sub Public Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged Dim Ids As String = (RadGrid1.SelectedItems(0).OwnerTableView.DataKeyValues(RadGrid1.SelectedItems(0).ItemIndex)("ID")) Dim dr() As DataRow = CallDS.Tables("RecCalls").Select("ID = '" + Ids + "'") If dr.Length > 0 Then lblCallDate.Text = CStr(dr(0)("PCName")) Return Else lblCallDate.Text = [String].Empty End If End Sub
Developer
-
hay guys i am still beginner in asp.net whn i tryed this code i got the "index out the bound of array" so plzz help me in this error Dim MyConn As New SqlConnection("Data Source=ASMAA-PC;Initial Catalog=LogFinity;Integrated Security=True") Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load 'Dim conn As String = "Data Source=ASMAA-PC;Initial Catalog=LogFinity;Integrated Security=True" Dim MyAdapter As New SqlDataAdapter MyConn.Open() MyAdapter.SelectCommand = New SqlCommand("Select * from RecCalls", MyConn) Try MyAdapter.Fill(CallDS) Finally MyConn.Close() End Try End Sub Public Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged Dim Ids As String = (RadGrid1.SelectedItems(0).OwnerTableView.DataKeyValues(RadGrid1.SelectedItems(0).ItemIndex)("ID")) Dim dr() As DataRow = CallDS.Tables("RecCalls").Select("ID = '" + Ids + "'") If dr.Length > 0 Then lblCallDate.Text = CStr(dr(0)("PCName")) Return Else lblCallDate.Text = [String].Empty End If End Sub
Developer
devsam wrote:
Public Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged Dim Ids As String = (RadGrid1.SelectedItems(0).OwnerTableView.DataKeyValues(RadGrid1.SelectedItems(0).ItemIndex)("ID"))
Your code is going in selected index change before there is any item in the grid. Write a check, something like this: IF NOT RadGrid1.SelectedItems.Count = 0 THEN and then write your code inside this If condition.
-
hay guys i am still beginner in asp.net whn i tryed this code i got the "index out the bound of array" so plzz help me in this error Dim MyConn As New SqlConnection("Data Source=ASMAA-PC;Initial Catalog=LogFinity;Integrated Security=True") Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load 'Dim conn As String = "Data Source=ASMAA-PC;Initial Catalog=LogFinity;Integrated Security=True" Dim MyAdapter As New SqlDataAdapter MyConn.Open() MyAdapter.SelectCommand = New SqlCommand("Select * from RecCalls", MyConn) Try MyAdapter.Fill(CallDS) Finally MyConn.Close() End Try End Sub Public Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged Dim Ids As String = (RadGrid1.SelectedItems(0).OwnerTableView.DataKeyValues(RadGrid1.SelectedItems(0).ItemIndex)("ID")) Dim dr() As DataRow = CallDS.Tables("RecCalls").Select("ID = '" + Ids + "'") If dr.Length > 0 Then lblCallDate.Text = CStr(dr(0)("PCName")) Return Else lblCallDate.Text = [String].Empty End If End Sub
Developer
-
devsam wrote:
Public Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged Dim Ids As String = (RadGrid1.SelectedItems(0).OwnerTableView.DataKeyValues(RadGrid1.SelectedItems(0).ItemIndex)("ID"))
Your code is going in selected index change before there is any item in the grid. Write a check, something like this: IF NOT RadGrid1.SelectedItems.Count = 0 THEN and then write your code inside this If condition.