Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
i am trying to add rows into data table but after add one row then click save the other row disappear because the post back
how can i add new rows but with stay of row before it
thnx
this is my code:


VB
Dim dcItemID = New DataColumn("ItemID", GetType(Int32))
            Dim dcUnit = New DataColumn("UnitID", GetType(Int32))
            Dim ItemPrice = New DataColumn("ItemPrice", GetType(Int32))
            Dim sellprice = New DataColumn("SellPrice", GetType(Int32))


            dt.Columns.Add(dcItemID)
            dt.Columns.Add(dcUnit)
            dt.Columns.Add(ItemPrice)
            dt.Columns.Add(sellprice)

            dt.Rows.Add(Convert.ToInt32(rcItemName.SelectedValue), Convert.ToInt32(rcUnitID.SelectedValue), tbItemPrice.Text, tbSellprice.Text)


What I have tried:

i tried every thing that found in internet plz help
Posted
Updated 26-Feb-18 3:54am
v2

1 solution

Before dt.Rows.Add() do a DIM dRow = dt.NewRow()
set the fields in dRow and then Add your dRow.
 
Share this answer
 
v2
Comments
Lisa775 28-Feb-18 23:22pm    
Thnx for u replay I tried that but it doesn't work
Herman<T>.Instance 2-Mar-18 10:57am    
please elaborate 'does not work'
Lisa775 6-Mar-18 6:56am    
It's still add only the last row I add
Herman<T>.Instance 6-Mar-18 7:42am    
Because of Post_Back you have to reload complete table to show.
So... the added row should be Committed in Db
Lisa775 12-Mar-18 2:26am    
thank u its work, i store it in ViewState

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900