Hi tareq16278,
Please refer below sample.
XML
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/1999/xhtml">
<url>
<MobileID>1</MobileID>
<pagetitle>asp net</pagetitle>
<Country>bangladesh</Country>
</url>
<url>
<MobileID>2</MobileID>
<pagetitle> পদবী সংশোধনের জন্য আবেদন (বেসরকারি মাদ্রাসা)</pagetitle>
<Country>bangladesh</Country>
</url>
</urlset>
HTML
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:Button ID="Ok" runat="server" Text="Ok" OnClick="Ok_Click" />
<asp:GridView ID="gvXML" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="MobileID" DataField="MobileID" />
<asp:BoundField HeaderText="pagetitle" DataField="pagetitle" />
<asp:BoundField HeaderText="Country" DataField="Country" />
</Columns>
</asp:GridView>
</div>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGrid(string.Empty, string.Empty, string.Empty);
}
}
private void BindGrid(string mobileId, string pageTitle, string country)
{
using (DataSet ds = new DataSet())
{
ds.ReadXml(Server.MapPath("~/XMLFile.xml"));
DataTable dt = ds.Tables["url"];
if (!string.IsNullOrEmpty(mobileId) && !string.IsNullOrEmpty(pageTitle) && !string.IsNullOrEmpty(country))
{
DataView dv = dt.DefaultView;
dv.RowFilter = string.Format("MobileID LIKE '%{0}%' AND pagetitle LIKE '%{1}%' AND Country LIKE '%{2}%'", mobileId, pageTitle, country);
dt = dv.ToTable();
}
gvXML.DataSource = dt;
gvXML.DataBind();
}
}
protected void Ok_Click(object sender, EventArgs e)
{
this.BindGrid(TextBox1.Text, TextBox2.Text, TextBox3.Text);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindGrid(String.Empty, String.Empty, String.Empty)
End If
End Sub
Private Sub BindGrid(ByVal mobileId As String, ByVal pageTitle As String, ByVal country As String)
Using ds As DataSet = New DataSet()
ds.ReadXml(Server.MapPath("~/XMLFile.xml"))
Dim dt As DataTable = ds.Tables("url")
If Not String.IsNullOrEmpty(mobileId) AndAlso Not String.IsNullOrEmpty(pageTitle) AndAlso Not String.IsNullOrEmpty(country) Then
Dim dv As DataView = dt.DefaultView
dv.RowFilter = String.Format("MobileID LIKE '%{0}%' AND pagetitle LIKE '%{1}%' AND Country LIKE '%{2}%'", mobileId, pageTitle, country)
dt = dv.ToTable()
End If
gvXML.DataSource = dt
gvXML.DataBind()
End Using
End Sub
Protected Sub Ok_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.BindGrid(TextBox1.Text, TextBox2.Text, TextBox3.Text)
End Sub
Screenshot