Hi ramco1917,
Refer below sample.
HTML
<script type="text/javascript">
function GetUserData(leadID) {
var request;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if (request != null) {
var url = "Default.aspx/GetUserData";
request.open("POST", url, false);
var params = "{id: '" + leadID + "'}";
request.setRequestHeader("Content-Type", "application/json");
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
document.getElementById('lblParentName').innerHTML = JSON.parse(request.responseText).d;
}
};
request.send(params);
}
return false;
}
</script>
<asp:Repeater ID="rptDetails" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>LeadID</th>
<th>LeadNumber</th>
<th>ParentName</th>
<th>ChildName</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:HiddenField ID="hdfLeadId" runat="server" Value='<%# Eval("LeadID") %>' />
<asp:Literal ID="ltrlNum" runat="server" Text="<%# Convert.ToString(Container.ItemIndex + 1) %>"></asp:Literal>
<a href='Redirect?pg=4&val=<%# Eval("LeadID") %>' data-popup="tooltip" title="Lead Details"
onclick='<%#string.Format("return GetUserData({0});",Eval("LeadID")) %>'>
<asp:Literal ID="ltr" runat="server" Text='<%# Eval("LeadNumber") %>'></asp:Literal>
</a>
</td>
<td><asp:Literal ID="ltrlNumber" runat="server" Text='<%# Eval("LeadNumber") %>'></asp:Literal></td>
<td><asp:Literal ID="ltrlParentName" runat="server" Text='<%# Eval("ParentName") %>'></asp:Literal></td>
<td><asp:Literal ID="ltrlChildName" runat="server" Text='<%# Eval("ChildName") %>'></asp:Literal></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<hr />
<asp:Label ID="lblParentName" runat="server" Font-Bold="true" />
Namespaces
C#
using System.Data;
using System.Web.Services;
VB.Net
Imports System.Data
Imports System.Web.Services
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.RepeaterGrid();
}
}
private void RepeaterGrid()
{
DataTable dt = GetData();
rptDetails.DataSource = dt;
rptDetails.DataBind();
}
[WebMethod]
public static string GetUserData(string id)
{
string parentName = string.Empty;
DataTable dt = GetData();
if (dt.Select("LeadID='" + id + "'").Length > 0)
{
parentName = dt.Select("LeadID='" + id + "'")[0]["ParentName"].ToString();
}
return parentName;
}
private static DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[4] {new DataColumn("LeadID"), new DataColumn("LeadNumber"),
new DataColumn("ParentName"), new DataColumn("ChildName") });
dt.Rows.Add("101", "4525", "Reva Pandey", "Cintu Pandey");
dt.Rows.Add("102", "4802", "Lexa Heda", "Logan Heda");
dt.Rows.Add("103", "4525", "Sujit Das", "Deva Das");
dt.Rows.Add("104", "4525", "Mahadev Dubery", "Rupa Dubery");
dt.Rows.Add("201", "2856", "Shanu khan", "Taimur Khan");
return dt;
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.RepeaterGrid()
End If
End Sub
Private Sub RepeaterGrid()
Dim dt As DataTable = GetData()
rptDetails.DataSource = dt
rptDetails.DataBind()
End Sub
<WebMethod>
Public Shared Function GetUserData(ByVal id As String) As String
Dim parentName As String = String.Empty
Dim dt As DataTable = GetData()
If dt.Select("LeadID='" & id & "'").Length > 0 Then
parentName = dt.Select("LeadID='" & id & "'")(0)("ParentName").ToString()
End If
Return parentName
End Function
Private Shared Function GetData() As DataTable
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn(3) {
New DataColumn("LeadID"),
New DataColumn("LeadNumber"),
New DataColumn("ParentName"),
New DataColumn("ChildName")})
dt.Rows.Add("101", "4525", "Reva Pandey", "Cintu Pandey")
dt.Rows.Add("102", "4802", "Lexa Heda", "Logan Heda")
dt.Rows.Add("103", "4525", "Sujit Das", "Deva Das")
dt.Rows.Add("104", "4525", "Mahadev Dubery", "Rupa Dubery")
dt.Rows.Add("201", "2856", "Shanu khan", "Taimur Khan")
Return dt
End Function
Screenshot