用datasource=xxx;databind();行数由数据源的行数决定,在程序里面能不能不绑定而增加行呢?
1楼
dim dst as new dataset()
dim dtb as datatable
dim drow as datarow
datasource=dst
dtb=dst.tables("tablename")
drow =dtb.newrow()
databind();
如果你的DataGride的DataSource是DataTable
那么
public sub btnAddNew_click(byval sender as object,e as eventAgrs)
dim dr as datarow
dim dt as datatable
dt =datagrid1.DataSource
dr =dt.newrow
dr.item(0)=''
dr.item(1)=''
...
dt.rows.add(dr)
dr.endedit
end sub
那么
public sub btnAddNew_click(byval sender as object,e as eventAgrs)
dim dr as datarow
dim dt as datatable
dt =datagrid1.DataSource
dr =dt.newrow
dr.item(0)=''
dr.item(1)=''
...
dt.rows.add(dr)
dr.endedit
end sub