Please help i would like to populate the above filelds upon selecting a record this fields has dropdown lists
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="StudentSearch.aspx.vb" Inherits="SMIS2022WEB.StudentSearch" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<script src="../Scripts/jquery-1.8.3.min.js"></script>
<script src="ASPSnippets_Pager.min.js"></script>
<script type="text/javascript">
$(function () {
GetCustomers(1);
});
$("[id*=txtSearch]").live("keyup", function () {
GetCustomers(parseInt(1));
});
$(".Pager .page").live("click", function () {
GetCustomers(parseInt($(this).attr('page')));
});
function SearchTerm() {
return jQuery.trim($("[id*=txtSearch]").val());
};
function GetCustomers(pageIndex) {
$.ajax({
type: "POST",
url: "StudentSearch.aspx/GetCustomers",
data: '{searchTerm: "' + SearchTerm() + '", pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}
var row;
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("Customers");
if (row == null) {
row = $("[id*=SearchGrid] tr:last-child").clone(true);
}
var footer = $("[id*=SearchGrid] tr:last-child").clone(true);
$("[id*=SearchGrid] tr").not($("[id*=SearchGrid] tr:first-child")).remove();
if (customers.length > 0) {
$.each(customers, function () {
var customer = $(this);
$("td", row).eq(0).html($(this).find("ADMNO").text());
$("td", row).eq(1).html($(this).find("Name").text());
$("td", row).eq(2).html($(this).find("Class").text());
$("td", row).eq(3).html($(this).find("Stream").text());
$("td", row).eq(4).html($(this).find("Sex").text());
$("td", row).eq(5).html($(this).find("Status").text());
$("td", row).eq(6).html($(this).find("studenttype").text());
$("td", row).eq(7).html($(this).find("select").text());
$("[id*=SearchGrid]").append(row);
row = $("[id*=SearchGrid] tr:last-child").clone(true);
});
$("[id*=SearchGrid]").append(footer);
var pager = xml.find("Pager");
$(".Pager").ASPSnippets_Pager({
ActiveCssClass: "current",
PagerCssClass: "pager",
PageIndex: parseInt(pager.find("PageIndex").text()),
PageSize: parseInt(pager.find("PageSize").text()),
RecordCount: parseInt(pager.find("RecordCount").text())
});
$(".Name").each(function () {
var searchPattern = new RegExp('(' + SearchTerm() + ')', 'ig');
$(this).html($(this).text().replace(searchPattern, "<span class = 'highlight'>" + SearchTerm() + "</span>"));
});
} else {
var empty_row = row.clone(true);
$("td:first-child", empty_row).attr("colspan", $("td", row).length);
$("td:first-child", empty_row).attr("align", "center");
$("td:first-child", empty_row).html("No records found for the search criteria.");
$("td", empty_row).not($("td:first-child", empty_row)).remove();
$("[id*=SearchGrid]").append(empty_row);
}
};
</script>
<body style="background-color: #FFFFFF">
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" style="background-color: #FFFFFF" Height="725px" BorderColor="#6699FF" BorderStyle="Double" Font-Size="Medium">
<table class="auto-style1">
<tr>
<td class="auto-style32" style="background-color: #FFFFFF">
<asp:GridView ID="SearchGrid" runat="server" AutoGenerateColumns="False" ItemStyle-Width="Auto" PageSize="25" ShowFooter="True" ShowHeaderWhenEmpty="True" Width="877px" Height="274px">
<Columns>
<asp:TemplateField HeaderText="Account">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("ADMNO") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="account0" runat="server" Text='<%# Bind("ADMNO") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Name">
<EditItemTemplate>
<asp:TextBox ID="Names" runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="Namesf" runat="server" Text='<%# Eval("Name") %>' Width="335px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Name" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Class">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Class") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="Classtf" runat="server" DataSourceID="Classdt" DataTextField="CLASS" DataValueField="CLASS">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Class" runat="server" Text='<%# Bind("Class") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Stream">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Stream") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="Streamdf" runat="server" DataSourceID="Streamdatad" DataTextField="Stream" DataValueField="Stream">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Stream" runat="server" Text='<%# Bind("Stream") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sex">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Sex") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="Sexdf" runat="server" DataSourceID="Sexddd" DataTextField="TYPE" DataValueField="TYPE">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="colour" runat="server" Text='<%# Bind("Sex") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Status") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Status0" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sudent Type" SortExpression="studenttype">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("studenttype") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="SudentType0" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>BOARDER</asp:ListItem>
<asp:ListItem>DAY</asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("studenttype") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField CommandName="Staff" HeaderText="Select" Text="Select" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</asp:Panel>
</div>
</form>
</body>
</html>
Account | Student Name | Class | Stream | Sex | Status | Sudent Type | Select |
19-01587 |
LUCKY JEREMIAH |
P7 |
RED |
|
|
BOARDER |
|
19-00002 |
AKANKWASA ELISHA |
P2 |
BLUE |
|
|
DAY |
|
19-00003 |
CHRIS GODWIN |
P3 |
BLUE |
|
|
DAY |
|
19-00004 |
ISABIRYE BENJAMIN |
P3 |
WHITE |
|
|
DAY |
|
19-00005 |
ISNGOMA ARCHELEOUS |
P1 |
BLUE |
|
|
DAY |
|
19-00006 |
KIBIRANGO DARIUS |
P2 |
BLUE |
|
|
BOARDER |
|
19-00007 |
KIGONGO SINAN |
P1 |
BLUE |
|
|
DAY |
|
19-00008 |
KIPLIMO PEREZ |
P3 |
BLUE |
|
|
BOARDER |
|
19-00009 |
LONYO JONATHAN |
P3 |
BLUE |
|
|
DAY |
|
Student Name |
Class |
Stream |
Sex |
Status |
Student Type |
Account |
|
|
|
|
|
BOARDER DAY |
|
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Public Class StudentSearch
Inherits System.Web.UI.Page
Private Shared PageSize As Integer = 25
Dim conString As String = ConfigurationManager.ConnectionStrings("SMIS2022ConnectionString").ConnectionString
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindDummyRow()
SearchGrid.DataBind()
End If
End Sub
Private Sub BindDummyRow()
Dim dummy As DataTable = New DataTable()
dummy.Columns.Add("ADMNO")
dummy.Columns.Add("Name")
dummy.Columns.Add("Class")
dummy.Columns.Add("Stream")
dummy.Columns.Add("Sex")
dummy.Columns.Add("Status")
dummy.Columns.Add("studenttype")
'dummy.Columns.Add("ACNOS")
'dummy.Columns.Add("RClass")
dummy.Rows.Add()
SearchGrid.DataSource = dummy
SearchGrid.DataBind()
'sample()
End Sub
<System.Web.Services.WebMethod()>
Public Shared Function GetCustomers(ByVal searchTerm As String, ByVal pageIndex As Integer) As String
Dim query As String = "[GetCustomers_Pager2022]"
Dim cmd As SqlCommand = New SqlCommand(query)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@SearchTerm", searchTerm)
cmd.Parameters.AddWithValue("@PageIndex", pageIndex)
cmd.Parameters.AddWithValue("@PageSize", 25)
cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output
Return GetData(cmd, pageIndex).GetXml()
End Function
Private Shared Function GetData(ByVal cmd As SqlCommand, ByVal pageIndex As Integer) As DataSet
Dim strConnString As String = ConfigurationManager.ConnectionStrings("SMIS2022ConnectionString").ConnectionString
Using con As SqlConnection = New SqlConnection(strConnString)
Using sda As SqlDataAdapter = New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using ds As DataSet = New DataSet()
sda.Fill(ds, "Customers")
Dim dt As DataTable = New DataTable("Pager")
dt.Columns.Add("PageIndex")
dt.Columns.Add("PageSize")
dt.Columns.Add("RecordCount")
dt.Rows.Add()
dt.Rows(0)("PageIndex") = pageIndex
dt.Rows(0)("PageSize") = 10
dt.Rows(0)("RecordCount") = cmd.Parameters("@RecordCount").Value
ds.Tables.Add(dt)
Return ds
End Using
End Using
End Using
End Function
Protected Sub SearchGrid_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SearchGrid.SelectedIndexChanged
End Sub
End Class