Hi nauna,
Refer below sample.
HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&key=AIzaSyBE1J5Pe_GZXBR_x9TXOv6TU5vtCSmEPW4"></script>
<script type="text/javascript">
$(function () {
$("div[class=pickup]").each(function () {
var textbox1 = $(this).find('[id*=TextBox1]');
var textbox2 = $(this).find('[id*=TextBox2]');
ApplyAutoComplete(textbox1);
ApplyAutoComplete(textbox2);
});
});
function ApplyAutoComplete(input) {
google.maps.event.addDomListener(window, 'load', function () {
var places;
for (var i = 0; i < input.length; i++) {
places = new google.maps.places.Autocomplete(input[i]);
}
google.maps.event.addListener(places, 'place_changed', function () {
var place = places.getPlace();
var address = place.formatted_address;
var mesg = "Address: " + address;
});
});
}
function Validate() {
$("div[class=pickup]").each(function (index) {
var textbox1 = $(this).find('[id*=TextBox1]').val();
if (textbox1 != '') {
var textbox2 = $(this).find('[id*=TextBox2]').val();
if (textbox2 == '') {
$(this).css("border-color", "red");
} else {
$(this).css("border-color", "");
}
}
});
return false;
}
</script>
<div>
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
<div class="pickup">
Id :
<asp:Label ID="Label1" runat="server" Text='<%# Eval("CustomerId") %>'></asp:Label>
PickUp :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
Origin :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</div>
</ItemTemplate>
</asp:ListView>
<asp:Button Text="Save" runat="server" OnClientClick="return Validate()" />
</div>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("CustomerId", typeof(int)) });
dt.Rows.Add(1);
dt.Rows.Add(2);
dt.Rows.Add(3);
this.ListView1.DataSource = dt;
this.ListView1.DataBind();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("CustomerId", GetType(Integer))})
dt.Rows.Add(1)
dt.Rows.Add(2)
dt.Rows.Add(3)
Me.ListView1.DataSource = dt
Me.ListView1.DataBind()
End If
End Sub
Screenshot