Sathya Narayan

Sathya Narayan

  • NA
  • 155
  • 65.3k

Spliting the Fname,mname,lname using listview to textbox

Jul 4 2014 8:22 AM
hi,
i am using listview control and 3 textboxes to fetch the values separatly.
How to split the firstname,middlename,lastname from listview to textbox.What would be the code for using to fetch the values from listview to textbox,so that it could be split to  textbox1,textbox2 and textbox3.This is how i am using the code.


To display to listview
 Public Sub FillList()
        sSql = "Select slno,COALESCE(firstname + ' ', '') + COALESCE(middlename + ' ', '')+ COALESCE(lastname + ' ', '') as 'Name',address as 'Address',contact as 'Contact No',emailid as 'Email Id',username as 'Username',pwd as 'Passward',cofmpwd as 'Confirm Passward' from tbl_usercreation"

        With ListView1
            .Clear()
            .View = View.Details
            .FullRowSelect = True
            .GridLines = True
            .Columns.Add("SLNO", 0)
            .Columns.Add("Name", 150)
            .Columns.Add("Address", 250)
            .Columns.Add("Contact No", 100)
            .Columns.Add("Email Id", 180)
            .Columns.Add("Username", 0)
            .Columns.Add("Passward", 0)
            .Columns.Add("Confirm Passward", 0)

            FillListView(ListView1, GetData(sSql))
        End With
    End Sub

To fetch from listviewcontrol  to textboxes 
 Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        If ListView1.SelectedItems.Count > 0 Then
            UserCreation.Label10.Text = ListView1.SelectedItems(0).SubItems(0).Text
            UserCreation.txtfirstname.Text = ListView1.SelectedItems(0).SubItems(1).Text
            UserCreation.txtmiddlename.Text = ListView1.SelectedItems(0).SubItems(1).Text
            UserCreation.txtlastname.Text = ListView1.SelectedItems(0).SubItems(1).Text
            UserCreation.txtaddress.Text = ListView1.SelectedItems(0).SubItems(2).Text
            UserCreation.txtcontact.Text = ListView1.SelectedItems(0).SubItems(3).Text
            UserCreation.txtemailid.Text = ListView1.SelectedItems(0).SubItems(4).Text
            UserCreation.txtusername.Text = ListView1.SelectedItems(0).SubItems(5).Text
            UserCreation.txtpasswd.Text = ListView1.SelectedItems(0).SubItems(6).Text
            UserCreation.txtcofmpwd.Text = ListView1.SelectedItems(0).SubItems(7).Text

        End If
    End Sub

Can any one help me??