protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt = this.GridView1.DataSource as DataTable;
string filter = "field1='" + this.DropDownList1.SelectedItem.Text + "' AND " +
"field2='" + this.DropDownList2.SelectedItem.Text + "' AND " +
"field3='" + this.TextBox1.Text + "' AND " +
"field4='" + this.TextBox2.Text + "'";
dt.DefaultView.RowFilter = filter;
this.GridView1.DataBind();
}
Sunday, March 30, 2008
remove duplicate row in datatable
Dim dt as new DataTable 'Assume this is the existing data table, populated somehow...
Dim dtNew as new DataTable
Dim dr as DataRow
Dim ID as Int32 = -1
dtNew=dt.Clone 'For having the same structure
for each dr in dt.Rows
If ID=-1 or ID <> Int32.Parse(dr("ID").ToString) Then
dtNew.ImportRow (dr)
ID = Int32.Parse(dr("ID").ToString)
End If
next
Hope this helps!!
Dim dtNew as new DataTable
Dim dr as DataRow
Dim ID as Int32 = -1
dtNew=dt.Clone 'For having the same structure
for each dr in dt.Rows
If ID=-1 or ID <> Int32.Parse(dr("ID").ToString) Then
dtNew.ImportRow (dr)
ID = Int32.Parse(dr("ID").ToString)
End If
next
Hope this helps!!
Subscribe to:
Posts (Atom)