I want to add textbox in datarow every time when user add table in button click. I don't know how to add textbox in datarow ?
Any help will be appreciate. Thank you and check my code below.
Dim TempRow As DataRow, tb As New TextBox
Dim i As Integer = 0
tb.ID = "txtaddQty" + i.ToString()
tb.Width = Unit.Pixel("100")
tb.Height = Unit.Pixel("30")
tb.Style.Add("position", "relative")
tb.Style.Add("top", "5px")
tb.Style.Add("left", "10px")
TempRow = TempTabl.NewRow
TempRow(" ") = ""
TempRow("0ItemID") = ItemID
TempRow("LedgerName") = LedgerName
TempRow("SerialFrom") = SerialFrom
TempRow("SerialTo") = SerialTo
TempRow("Qty") = Qty
TempRow("Rate") = Rate
TempRow("AddQty") = //I want to add textbox is here //
Dim i As Integer = 0
tb.ID = "txtaddQty" + i.ToString()
tb.Width = Unit.Pixel("100")
tb.Height = Unit.Pixel("30")
tb.Style.Add("position", "relative")
tb.Style.Add("top", "5px")
tb.Style.Add("left", "10px")
TempRow = TempTabl.NewRow
TempRow(" ") = ""
TempRow("0ItemID") = ItemID
TempRow("LedgerName") = LedgerName
TempRow("SerialFrom") = SerialFrom
TempRow("SerialTo") = SerialTo
TempRow("Qty") = Qty
TempRow("Rate") = Rate
TempRow("AddQty") = //I want to add textbox is here //
Naidu AMMANPosted Oct 10, 2014, 3:09 AM
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Dim strsql As String = ""
''If rdbBetweenDates.Checked = True Then
'' If Date > DTto.Value.Date Then
'' MsgBox("From date should not be greater than To Date Please Change To Date", MsgBoxStyle.Critical, "Dates")
'' Exit Sub
'' ElseIf DTto.Value.Date.Subtract.Days > 31 Then
'' MsgBox("Duration between Dates Should not be greater than 31 days", MsgBoxStyle.Critical, "Dates")
'' Exit Sub
'' End If
''End If
''strsql = "select VehicleNumber,VehicleType,format(INDATE,'dd/MM/yyyy') as VehicleINDATE,format(INDATE,'HH:mm:ss') as VehicleINTIME,InSlip,OutSlip,DeviceID,Amount,SupervisorID,Fromtime,Totime,ExtraAmountperHour,Billtype,SupervisorName,ShiftNo from tblcollection where VehicleType='" & cmbvehicletype.Text & "'" ''where INDATE>=#" & DtFrom.Value.Date & "# and INDATE<=#" & DTto.Value.Date & "#"
strsql = "SELECT tblCollection.Amount, tblCollection.VehicleNumber, tblCollection.VehicleType, format(INDATE,'dd/MM/yyyy') AS VehicleINDATE, format(INDATE,'HH:mm:ss') AS VehicleINTIME, tblCollection.DeviceID, tblCollection.SupervisorID, tblCollection.Fromtime, tblCollection.Totime, tblCollection.Billtype, tblCollection.SupervisorName, tblCollection.ShiftNo, tblCollection.ExtraAmountperHour FROM tblCollection WHERE tblCollection.INDATE Between #" & DtFrom.Value.Date.ToString("MM/dd/yyyy 06:00:00") & "# And #" & DTto.Value.Date.ToString("MM/dd/yyyy 05:59:59") & "# AND VehicleType='" & cmbvehicletype.Text & "'"
Dim m_ds As New DataSet
Dim m_db As New CDataAccess
m_ds = m_db.getdata(strsql, strconnection)
If Not m_ds Is Nothing Then
DataGridView1.DataSource = m_ds.Tables(0)
Else
MsgBox("No Records found", MsgBoxStyle.Information)
End If
End Sub
Private Sub DataGridView1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
If DataGridView1.SelectedRows.Count > 0 Then
txtAmount.Text = DataGridView1.SelectedRows(0).Cells(0).Value.ToString()
''m_passtypes.txtVehicleType.Text = DataGridView1.SelectedRows(0).Cells(2).Value.ToString()
txtVehicleNumber.Text = DataGridView1.SelectedRows(0).Cells(1).Value.ToString()
txtINDATE.Text = DataGridView1.SelectedRows(0).Cells(3).Value.ToString()
''txtInslip.Text = DataGridView1.SelectedRows(0).Cells(5).Value.ToString()
''txtoutslip.Text = DataGridView1.SelectedRows(0).Cells(6).Value.ToString()
txtDevice.Text = DataGridView1.SelectedRows(0).Cells(5).Value.ToString()
txtsupervisorId.Text = DataGridView1.SelectedRows(0).Cells(6).Value.ToString()
Txtfromtime.Text = DataGridView1.SelectedRows(0).Cells(7).Value.ToString()
txttotime.Text = DataGridView1.SelectedRows(0).Cells(8).Value.ToString()
txtBillType.Text = DataGridView1.SelectedRows(0).Cells(9).Value.ToString()
txtsupervisorName.Text = DataGridView1.SelectedRows(0).Cells(10).Value.ToString()
txtShiftno.Text = DataGridView1.SelectedRows(0).Cells(11).Value.ToString()
txtExtraamountperh.Text = DataGridView1.SelectedRows(0).Cells(12).Value.ToString()
End If
End sub
End Class
VulpesPosted Sep 25, 2014, 9:03 AM
http://msdn.microsoft.com/en-us/library/system.data.datacolumn.datatype(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1