Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Okay,

 

I have an application that I need to create a local DataTable bound to a DataGrid so the user can create their list of parts prior to inserting them into the database.

 

I had been using a simple CheckBoxList, but the formatting limitations were really ticking me off (extraneous spaces removed automatically), so I decided to switch to a bound DataGrid.

 

Here is the code I have for when the user clicks the "Add" button:

 

Dim NewTableRow As System.Data.DataRow = dsSelectedParts.Tables("dtSelectedParts").NewRow()

If Len(Trim(txtPartNum.Text)) > 0 Then
  PartNumber = UCase(txtPartNum.Text)
  GoodPart = ValidPart(PartNumber)
Else
  GoodPart = False
End If

If GoodPart Then
  NewTableRow("RowID") = PartIndex
  NewTableRow("PartNumber") = Session("PartNum")
  NewTableRow("PartDesc") = Session("PartDesc")
  NewTableRow("PartMBS") = Session("PartMBS")
  NewTableRow("PartRev") = Session("PartRev")
  NewTableRow("PartDwg") = Session("PartDwg")

  dsSelectedParts.Tables("dtSelectedParts").Rows.Add(NewTableRow)
  Dim RowCount As Integer = dsSelectedParts.Tables("dtSelectedParts").Rows.Count.ToString()
  Session("TempVar") = dsSelectedParts.Tables("dtSelectedParts").Rows(PartIndex).Item("PartDesc").ToString
  dgSelectedParts.DataBind()

 

I have the code stop on the assignment of Session("TempVar"), and the first time, the PartIndex value is 0, and the Row.Count propery of the table is 1. The second time, the PartIndex value is 1, but the Rows.Count property is STILL 1.

 

What am I missing here? This seems SO SIMPLE!!!!

 

Kahuna

The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order.

Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing.

-- Vincent T. Lombardi

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...