C1GridView add handler

Posted by: marlonschreiber on 10 September 2017, 11:44 am EST

  • Posted 10 September 2017, 11:44 am EST

    Hi to all,
    I dynamically add datagridview to tabs:
    Dim grid As New C1GridView()
    grid.ID = "C1GridView1" & myCounter.ToString
    grid.AutoGenerateSelectButton = True
    grid.AllowSorting = True
    grid.AllowPaging = True
    grid.Width = 800
    grid.Height = 300
    grid.DataSourceID = SqlDataSource1.ID
    TabContainer1.Tabs(tabcount).Controls.Add(grid)
    grid.DataBind()

    This works! Puhhhh :)
    As You see I add a selectButton! How do i add a handler that redirects to another page and passes the value of the column GUID?
    Thanks for Your help!
  • Replied 10 September 2017, 11:44 am EST

    Hello,

    You may handle SelectedIndexChanged event of the grid and can redirect the page to the desired one. However, I am not clear about the second requirement so could you kindly provide some information on same so that I can assist you further ?

    Regards
    Ashish
  • Replied 10 September 2017, 11:44 am EST

    Hi Ashish,
    as you see I create the datagrid dynamically at Page_load event!
    Therfore the selected Index event does not exist!
    How can I generate such a method?
  • Replied 10 September 2017, 11:44 am EST

    Hi I came so far:
    This Code generates my Gridview:
     Dim grid As New C1GridView()
    With grid
    .ID = "C1GridView1" & tabcount.ToString
    .AutoGenerateSelectButton = True
    .AllowSorting = True
    .AllowPaging = True
    .ScrollMode = ScrollMode.Auto
    '.Theme = "Aristo"
    .Width = 800
    .Height = 300
    .DataSourceID = sds.ID
    End With
    TabContainer1.Tabs(tabcount).Controls.Add(grid)
    grid.DataBind()
    AddHandler grid.SelectedIndexChanged, AddressOf DevicesGridView_RowCommand

    The Sub ..._Row command fires correctly
    Sub DevicesGridView_RowCommand(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim gridview As C1GridView = sender
    TextBox1.Text = gridview.SelectedRow.DataItem(1).ToString
    End Sub

    But where I want to set the Value of textBox1 I get an error:
    "Die Objektvariable oder die With-Blockvariable wurde nicht festgelegt."
    Can someone help?
  • Replied 10 September 2017, 11:44 am EST

    Anybody has an idea?
    I'm stuck so far :(
  • Replied 10 September 2017, 11:44 am EST

    Hello,

    You can use the following code for same:


    Sub DevicesGridView_RowCommand(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim gridview As C1GridView = sender
    TextBox1.Text = gridview.SelectedRow.Cells(2).Text
    End Sub



    Regards
    Ashish
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels