Hi ramco1917,
Please refer below sample.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
HTML
<body class="container">
<form id="form1" runat="server">
<asp:Repeater ID="rptOrder" runat="server">
<HeaderTemplate>
<table class="table table responsive">
<tr>
<th>CustomerId</th>
<th>Description</th>
<th></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="lblCustomerId" runat="server" Text='<%#Eval ("Id") %>' /></td>
<td><asp:Label ID="Label1" runat="server" Text='<%#Eval ("Description") %>' /></td>
<td><asp:Button Text="Add" runat="server" OnClick="Add" /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<div id="modal_form_horizontal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-info">
<h5 class="modal-title">
Show Record</h5>
<button type="button" class="close" data-dismiss="modal">
×</button>
</div>
<div class="form-horizontal">
<div class="modal-body" style="padding-left: 40px;padding-right: 20px;">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label>Order</label> <span style="color: red">*</span>
<asp:DropDownList ID="ddlOrders" runat="server" class="form-control">
</asp:DropDownList>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-link" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script type="text/javascript">
function ShowPopup() {
$('#modal_form_horizontal').modal("show");
};
</script>
</form>
</body>
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
VB.Net
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
List<Data> items = new List<Data>();
items.Add(new Data { Id = "ALFKI", Description = "Alfreds Futterkiste" });
items.Add(new Data { Id = "ANATR", Description = "Around the Horn" });
items.Add(new Data { Id = "ANTON", Description = "Island Trading" });
items.Add(new Data { Id = "AROUT", Description = "La maison d'Asie" });
rptOrder.DataSource = items;
rptOrder.DataBind();
}
}
protected void Add(object sender, EventArgs e)
{
ddlOrders.Items.Clear();
string id = (((sender as Button).NamingContainer as RepeaterItem).FindControl("lblCustomerId") as Label).Text;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT OrderID,Freight FROM [Orders] WHERE CustomerID = @CustomerID", con))
{
cmd.Parameters.AddWithValue("@CustomerID", id);
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
ddlOrders.Items.Add(new ListItem { Text = sdr["Freight"].ToString(), Value = sdr["OrderID"].ToString() });
}
}
con.Close();
}
}
ddlOrders.Items.Insert(0, new ListItem { Text = "Select Order", Value = "" });
ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
}
public class Data
{
public string Id { get; set; }
public string Description { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim items As List(Of Data) = New List(Of Data)()
items.Add(New Data With {
.Id = "ALFKI",
.Description = "Alfreds Futterkiste"
})
items.Add(New Data With {
.Id = "ANATR",
.Description = "Around the Horn"
})
items.Add(New Data With {
.Id = "ANTON",
.Description = "Island Trading"
})
items.Add(New Data With {
.Id = "AROUT",
.Description = "La maison d'Asie"
})
rptOrder.DataSource = items
rptOrder.DataBind()
End If
End Sub
Protected Sub Add(ByVal sender As Object, ByVal e As EventArgs)
ddlOrders.Items.Clear()
Dim id As String = (TryCast((TryCast((TryCast(sender, Button)).NamingContainer, RepeaterItem)).FindControl("lblCustomerId"), Label)).Text
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand("SELECT OrderID,Freight FROM [Orders] WHERE CustomerID = @CustomerID", con)
cmd.Parameters.AddWithValue("@CustomerID", id)
con.Open()
Using sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
ddlOrders.Items.Add(New ListItem With {
.Text = sdr("Freight").ToString(),
.Value = sdr("OrderID").ToString()
})
End While
End Using
con.Close()
End Using
End Using
ddlOrders.Items.Insert(0, New ListItem With {
.Text = "Select Order",
.Value = ""
})
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "ShowPopup();", True)
End Sub
Public Class Data
Public Property Id As String
Public Property Description As String
End Class
Screenshot