c1Gridview Example for RowDatabound Event

Posted by: krmartin on 10 September 2017, 11:27 am EST

  • Posted 10 September 2017, 11:27 am EST

    I have worked with C1webgrid in the past using the ItemDatabound event to work with controls on the edit template at run-time.    Below is an example of code from a c1webgrid. I am looking for an example of how to accomplish the same thing using the c1gridview?   Thank you


            If e.Item.ItemType = C1.Web.C1WebGrid.C1ListItemType.EditItem Then
                Dim lblchemicalid As Label = CType(e.Item.Cells(6).Controls(1), Label)
                chemicalid = Val(lblchemicalid.Text)
                Dim ddlchemical As DropDownList = CType(e.Item.Cells(1).Controls(7), DropDownList)
                ddlchemical.DataSource = mfidb.DDLPoolChemicalRS(txtdate.Text)
                ddlchemical.DataValueField = "chemicalid"
                ddlchemical.DataTextField = "chemical"
                ddlchemical.DataBind()
                Dim item As ListItem
                item = ddlchemical.Items.FindByValue(chemicalid)
                If Not item Is Nothing Then item.Selected = True


         end if


     

  • Replied 10 September 2017, 11:27 am EST

    Hi,
     
    you need to replace
     
    e.Item to e.Row
    e.ItemItemType to e.Row.RowType
     
    If e.Item.ItemType =
    C1.Web.C1WebGrid.C1ListItemType.EditItem Then
    to
    If ((e.Row.RowType = C1GridViewRowType.DataRow) And
    ((e.Row.RowState And C1GridViewRowState.Edit) <> 0))
     
    Regards,
    Sergey.
     
    style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
    wrote: href="news:223214@10.0.1.98">news:223214@10.0.1.98...

    I have worked with C1webgrid in the past using the ItemDatabound event to
    work with controls on the edit template at run-time.    Below
    is an example of code from a c1webgrid. I am looking for an example of how to
    accomplish the same thing using the c1gridview?   Thank you


            If e.Item.ItemType =
    C1.Web.C1WebGrid.C1ListItemType.EditItem
    Then
                Dim
    lblchemicalid As Label = CType(e.Item.Cells(6).Controls(1),
    Label)
               
    chemicalid =
    Val(lblchemicalid.Text)
               
    Dim ddlchemical As DropDownList = CType(e.Item.Cells(1).Controls(7),
    DropDownList)
               
    ddlchemical.DataSource =
    mfidb.DDLPoolChemicalRS(txtdate.Text)
               
    ddlchemical.DataValueField =
    "chemicalid"
               
    ddlchemical.DataTextField =
    "chemical"
               
    ddlchemical.DataBind()
               
    Dim item As
    ListItem
               
    item =
    ddlchemical.Items.FindByValue(chemicalid)
               
    If Not item Is Nothing Then item.Selected = True


         end if


     




    href="http://helpcentral.componentone.com/cs/forums/p/80845/223214.aspx#223214">http://helpcentral.componentone.com/cs/forums/p/80845/223214.aspx#223214

Need extra support?

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

Learn More

Forum Channels