Site Search:
Sign in | Join | Help
4Penny.net

ComponentArt

Creating an editable textbox inside a Componentart Grid

This will demonstrate how to create an editable textbox inside of a janus grid, and then how to update the dataset with the new data.

Add a column in the grid that references a 'ServerSideTemplate':

<ComponentArt:GridColumn DataCellServerTemplateId="unitPriceTemplate" />

Be sure that any field that you want to reference in the template is in the grid. It's OK to make it non-visible:

<ComponentArt:GridColumn DataField="unitprce" Visible="false" />

 

Add the template

<ServerTemplates>
  <ComponentArt:GridServerTemplate ID
="unitPriceTemplate">
    <Template
>
      <asp:TextBox runat="server" Text='<%# Container.DataItem("unitprce") %>'
 ID="unitprce"></asp:TextBox
>
    </Template
>
  </ComponentArt:GridServerTemplate
>
</ServerTemplates>

Now we need to be able to get a reference to the template field in the code behind. In this example, we are looping through the grid using the 'getSelectedItems' method of the grid.

Protected Sub btnRemoveHolds_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemoveHolds.Click

Dim griditem As ComponentArt.Web.UI.GridItem
Dim intRowID As
System.Int64
Dim strSopnumber As
String
Dim intSoptype As
System.Int16
Dim intLineItemSeq As
System.Int64
Dim selectedItems As
ComponentArt.Web.UI.GridItemCollection
Dim dblUnitPrice As
Double
Dim txtUnitPrice As
TextBox
selectedItems =
Me.grdOrders.GetCheckedItems(Me.grdOrders.Levels(0).Columns("removeHold"
))

For Each griditem In selectedItems
  'get a reference to the rowID that we'll change
  strSopnumber = griditem("sopnumbe"
)
  intSoptype = griditem(
"soptype"
)
  intLineItemSeq = griditem(
"lnitmseq"
)

  txtUnitPrice = Me.grdOrders.FindControl(0, 5, griditem, "txtUnitPrice")
  dblUnitPrice = txtUnitPrice.Text
 

  'update the price
  ofacSOP10200.SOP10200_UPD_UnitPrice(strSopnumber, intSoptype, intLineItemSeq, dblUnitPrice)

Next

bindgrid()


End Sub

 

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.