Hii tareq16278,
Please refer below sample.
XML
<?xml version="1.0" encoding="utf-8" ?>
<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>
<loc>/train/1/good-jjob</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/2/-asp-net</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/3/asp-null</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/4/aspbig</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/5/lovly</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/asp/ok</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/7/করতা-একপ্রেস</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/8/জোনাকি-asp</loc>
<lastmod>2022-11-18</lastmod>
</url>
<url>
<loc>/train/9/youto-big</loc>
<lastmod>2022-11-18</lastmod>
</url>
</urlset>
HTML
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" Text="Search" runat="server" OnClick="OnSearch" />
<hr />
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="loc" HeaderText="Location" />
<asp:BoundField DataField="lastmod" HeaderText="Last Modified" />
</Columns>
</asp:GridView>
Nampespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGrid();
}
}
private void BindGrid(string prefix = "")
{
using (DataSet ds = new DataSet())
{
ds.ReadXml(Server.MapPath("~/XMLFile.xml"));
DataTable dt = ds.Tables["url"];
if (!string.IsNullOrEmpty(prefix))
{
DataView dataView = dt.DefaultView;
dataView.RowFilter = "loc LIKE '%" + prefix + "%'";
dt = dataView.ToTable();
}
gvCustomers.DataSource = dt;
gvCustomers.DataBind();
}
}
protected void OnSearch(object sender, EventArgs e)
{
this.BindGrid(txtSearch.Text);
}
VB.Net
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindGrid()
End If
End Sub
Private Sub BindGrid(ByVal Optional prefix 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(prefix) Then
Dim dataView As DataView = dt.DefaultView
dataView.RowFilter = "loc LIKE '%" & prefix & "%'"
dt = dataView.ToTable()
End If
gvCustomers.DataSource = dt
gvCustomers.DataBind()
End Using
End Sub
Protected Sub OnSearch(ByVal sender As Object, ByVal e As EventArgs)
Me.BindGrid(txtSearch.Text)
End Sub
Screenshot