我想,如果它满足的条件从GridView
删除完整的行。从一个GridView删除完整的行当行满足条件
在这里我有
a Description Column from Product table in database
与一个GridView
填充。
我在VB应用程序中设置的sqlcommand
只select the Description which does not contain the String s
。
这里String s has two keywords "Tomatoes" and "Apple"
。所以Sql Query应该检索Description column that does not have "Tomatoes" and "Apple"
。
因此Gridview
应通过去除满足条件的行进行更新。
我对着在去除
Description row in GridView
其中有“西红柿”和“苹果”有困难。我试图填充另一个GridView控件的结果,但它并没有在网页中,尽管事实上这一切都是正确的,因为我已经看到了,我指定的一些断点值显示。任何建议或想法?
这里是我的代码:
Dim cmd1 = New SqlCommand(" SELECT DISTINCT [Description] FROM [Product] WHERE ([Description] LIKE '%' + @Description + '%')", conn)
cmd1.Parameters.AddWithValue("@Description", s)
MsgBox("NO")
For i As Integer = 0 To GridView1.Rows.Count - 1
DA.SelectCommand = cmd1
DA.Fill(dt)
'row is of a GridViewRow datatype As GridView1.Rows
row.Cells.RemoveAt(i) '' do not know if it is correct or not
'GridView3.DataSource = '' dt tried with no luck
'GridView3.DataBind() '' tried with no luck
cmd1.Dispose()
DA.Dispose()
dt.Clear()
dt.Dispose()
Next
End If
更正确的实施方法是,从GridView的数据源中删除行,然后调用的DataBind(),而不是它已经被加载之后从GridView的数据。看到线程[这里](http://stackoverflow.com/questions/592106/how-to-delete-row-from-gridview)。 –
@SandraWalters所以我怎么才能实现只从GridView中删除行,因为我不想从sqlDataSource中删除原始的'Description',而只是从GridView中删除 – HShbib