조건을 만족하면 GridView
에서 전체 행을 제거하려고합니다.행이 조건을 만족할 때 gridview에서 전체 행 제거
는 여기에서 나는 GridView
채워되어있는
a Description Column from Product table in database
sqlcommand
을 내 vb 앱에만 select the Description which does not contain the String s
으로 설정합니다.
여기 String s has two keywords "Tomatoes" and "Apple"
. 따라서 Sql 쿼리는 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에서 데이터를 제거하는 대신 GridView의 데이터 소스에서 행을 제거한 다음 DataBind()를 호출하는 것입니다. thread [here] (http://stackoverflow.com/questions/592106/how-to-deleterowrow-from-gridview)를 참조하십시오. –
@SandraWalters 그래서 어떻게 sqlDataSource에서 오리지널'Description'을 지우고 싶지는 않지만 GridView에서만 행을 삭제하려고 할 수 있습니다 – HShbib