Hi
I am use select query and fill in datatable,in that datatable i need to add new row on top of the dataable,once add and need to bind in gridview,my code as follows
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim da As SqlDataAdapter
Dim fdatas As New DataTable
con = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ToString())
cmd = New SqlCommand
da = New SqlDataAdapter
cmd.CommandText = "select distinct [UserName],[filePath],[document_filename] from AnnotationMark where [filePath]='" + filepath + "' "
cmd.Connection = con
da.SelectCommand = cmd
con.Open()
da.Fill(fdatas)
con.Close()
con.Dispose()
da.Dispose()
If fdatas.Rows.Count > 0 Then
Dim dr As DataRow = fdatas.NewRow()
dr.Table(0)("UserName") = "View All"
dr.Table(0)("filePath") = filepath
dr.Table(0)("document_filename") = "View All"
fdatas.Rows.Add(dr)
End If
gridAnnotation.DataSource = fdatas
gridAnnotation.DataBind()
In fdatas datatable i get 5 vlaues,and i try to add new row on top of fdatas datatable,what happen all values diappear only added new row only can see in fdatas datatable.
So how to add new row on top of fdatas with existing values.
If i use following code it add row at last of fdatas datatable
If fdatas.Rows.Count > 0 Then
Dim dr As DataRow = fdatas.NewRow()
dr("UserName") = "View All"
dr("filePath") = filepath
dr("document_filename") = "View All"
fdatas.Rows.Add(dr)
End If
Note: need to add top of the fdatas ,so need to specify position
Regards
Aravind