Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Linkbutton control problem

Linkbutton control problem

Scheduled Pinned Locked Moved ASP.NET
help
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rameez Raja
    wrote on last edited by
    #1

    hi all , iam not able to add linkbutton control to table cell can any body suggest me where iam doing wrong i have used following code to add linkbutton control to table cells

    Dim myarray() As Integer = {0, 1, 2, 1, 4, 5, 6, 7, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
    Dim d As Integer
    For d = 0 To 31
    Dim tc As TableCell = New TableCell
    If myarray(d) = 1 Then
    Dim linkbutton As LinkButton = New LinkButton()
    linkbutton.ID = "lnkbutton"
    linkbutton.Text = " click here"
    tc.Controls.Add(linkbutton)
    'tc.BackColor = Color.DarkGreen
    Else
    tc.BackColor = Color.Yellow
    End If
    tc.Text = " "
    trow.Cells.Add(tc)
    Next

            Table.Rows.Add(trow)
    

    or alternate way how i do that. Best regards Rameez

    A N 2 Replies Last reply
    0
    • R Rameez Raja

      hi all , iam not able to add linkbutton control to table cell can any body suggest me where iam doing wrong i have used following code to add linkbutton control to table cells

      Dim myarray() As Integer = {0, 1, 2, 1, 4, 5, 6, 7, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
      Dim d As Integer
      For d = 0 To 31
      Dim tc As TableCell = New TableCell
      If myarray(d) = 1 Then
      Dim linkbutton As LinkButton = New LinkButton()
      linkbutton.ID = "lnkbutton"
      linkbutton.Text = " click here"
      tc.Controls.Add(linkbutton)
      'tc.BackColor = Color.DarkGreen
      Else
      tc.BackColor = Color.Yellow
      End If
      tc.Text = " "
      trow.Cells.Add(tc)
      Next

              Table.Rows.Add(trow)
      

      or alternate way how i do that. Best regards Rameez

      A Offline
      A Offline
      AhsanS
      wrote on last edited by
      #2

      You are doing it the right way. What error are you getting.

      Ahsan Ullah Senior Software Engineer

      R 1 Reply Last reply
      0
      • A AhsanS

        You are doing it the right way. What error are you getting.

        Ahsan Ullah Senior Software Engineer

        R Offline
        R Offline
        Rameez Raja
        wrote on last edited by
        #3

        Thanks Ahsanullah for reply. linkbutton control is not added to table cell i mean nothing to added into cell. i have to add linkbuton control to table cells dynamically. please suggest me where iam doing mistake . best regards Rameez

        1 Reply Last reply
        0
        • R Rameez Raja

          hi all , iam not able to add linkbutton control to table cell can any body suggest me where iam doing wrong i have used following code to add linkbutton control to table cells

          Dim myarray() As Integer = {0, 1, 2, 1, 4, 5, 6, 7, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
          Dim d As Integer
          For d = 0 To 31
          Dim tc As TableCell = New TableCell
          If myarray(d) = 1 Then
          Dim linkbutton As LinkButton = New LinkButton()
          linkbutton.ID = "lnkbutton"
          linkbutton.Text = " click here"
          tc.Controls.Add(linkbutton)
          'tc.BackColor = Color.DarkGreen
          Else
          tc.BackColor = Color.Yellow
          End If
          tc.Text = " "
          trow.Cells.Add(tc)
          Next

                  Table.Rows.Add(trow)
          

          or alternate way how i do that. Best regards Rameez

          N Offline
          N Offline
          Neeraj Arora
          wrote on last edited by
          #4

          hopefully you have created tablerow before loop. otherwise code is perfect.

          R 1 Reply Last reply
          0
          • N Neeraj Arora

            hopefully you have created tablerow before loop. otherwise code is perfect.

            R Offline
            R Offline
            Rameez Raja
            wrote on last edited by
            #5

            Here is my complete code

            Dim myarray() As Integer = {0, 1, 2, 1, 4, 5, 6, 7, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
            Dim d As Integer
            Dim trow As TableRow = New TableRow()
            For d = 0 To 31
            Dim tc As TableCell = New TableCell
            If myarray(d) = 1 Then
            Dim lnkbutton As LinkButton = New LinkButton()
            lnkbutton.ID = "lnkbutton"
            lnkbutton.Text = "Click Here dear "
            lnkbutton.PostBackUrl = ""
            AddHandler lnkbutton.Click, AddressOf OnClickLink
            tc.Controls.Add(lnkbutton)
            Else
            tc.BackColor = Color.Yellow
            End If
            tc.Text = " "
            trow.Cells.Add(tc)

                Next
                Table1.Rows.Add(trow)
            

            and here is event handler for that.

            Protected Sub OnClickLink(ByVal sender As Object, ByVal e As EventArgs)
            FormView1.Visible = True
            Dim myConnection As New SqlConnection("Server=localhost;Database=xyz;uid=sa;pwd=xxxx")
            Dim ad As New SqlDataAdapter("SELECT * FROM name of table", myConnection)
            Dim ds As New DataSet()
            ad.Fill(ds)
            FormView1.DataSource = ds
            FormView1.DataBind()

            End Sub
            

            in above code nothing is added to table cell can any body suggest me where iam doing wrong . Best Regards Rameez

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups