Click here to Skip to main content
15,902,492 members

Comments by Member 12119549 (Top 29 by date)

Member 12119549 21-Nov-15 2:39am View    
i know it is ..but what code we write behind it.. here i just got the index ..but
dt.Rows.Remove(dt.Rows(e.RowIndex))
in this line ..how can i make changes?
Member 12119549 18-Nov-15 7:30am View    
yes i am just practicing it by adding values to a grid by datatable.. here's my code..
'creating dataTable
'Dim dt As New DataTable()
Dim dr As DataRow
dt.TableName = "AuthorBooks"
dt.Columns.Add(New DataColumn("AuthorName", GetType(String)))
dt.Columns.Add(New DataColumn("BookName", GetType(String)))
dt.Columns.Add(New DataColumn("BookType", GetType(String)))
dt.Columns.Add(New DataColumn("Publisher", GetType(String)))
dr = dt.NewRow()
dt.Rows.Add(dr)

ViewState("AuthorBooks") = dt

GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Private Sub AddNewRecordRowToGrid()

If ViewState("AuthorBooks") IsNot Nothing Then

Dim dtCurrentTable As DataTable = DirectCast(ViewState("AuthorBooks"), DataTable)
Dim drCurrentRow As DataRow = Nothing
If dtCurrentTable.Rows.Count > 0 Then

For i As Integer = 1 To dtCurrentTable.Rows.Count
drCurrentRow = dtCurrentTable.NewRow()
drCurrentRow("AuthorName") = TextBox1.Text
drCurrentRow("BookName") = TextBox2.Text
drCurrentRow("BookType") = TextBox4.Text
drCurrentRow("Publisher") = TextBox5.Text

Next

If dtCurrentTable.Rows(0)(0).ToString() = "" Then
dtCurrentTable.Rows(0).Delete()
dtCurrentTable.AcceptChanges()
End If
dtCurrentTable.Rows.Add(drCurrentRow)
ViewState("AuthorBooks") = dtCurrentTable

GridView1.DataSource = dtCurrentTable
GridView1.DataBind()
End If
End If
End Sub

Should i iterate through the loop as i have tried it in a list and got succedded.But here i am not able to do as such..that's how i did it in list..
Dim result As Boolean = True
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
If VAR3 = ListBox1.Items(i).ToString Then
result = False
End If
Next
If result = False Then
Label1.Text = "Item already exits"
End If
If result = True Then
ListBox1.Items.Add(TextBox1.Text + "" + TextBox2.Text)
End If
Try
Label1.Text = ListBox1.SelectedItem.Text
Catch

Need answers plzzzz.........

Member 12119549 17-Nov-15 1:20am View    
Any help @OriginalGriff sir you always come to my rescue
Member 12119549 16-Nov-15 22:15pm View    
tried it but getting error identifier expected.. :(.. plz get me out of this prb
Member 12119549 16-Nov-15 14:46pm View    
thanks got it