I am trying to update GridView Colum color with the current value from the table using this code.
But the GridView column does not show automatically yet i wanted it to be automatically showed after selecting the value from dropdown list stream.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SearchStudentdata.aspx.vb" Inherits="UNIFORMWEB2023.SearchStudentdata" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../Scripts/jquery-1.8.3.min.js"></script>
<script src="../Datatables/datatables.js"></script>
<link href="../Datatables/datatables.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("[id*=StudentGrid]").DataTable({
bLengthChange: true,
lengthMenu: [[15, 20, -1], [15, 20, "All"]],
bFilter: true,
bSort: true,
bPaginate: true
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>
<asp:Button ID="Button1" runat="server" Text="Submit Record" Width="156px" Height="34px" />
</td>
<td rowspan="2"> </td>
</tr>
<tr>
<td colspan="4">
<asp:GridView ID="StudentGrid" runat="server" AutoGenerateColumns="False" ItemStyle-Width="Auto" CellSpacing="1" ClientIDMode="Static">
<Columns>
<asp:CommandField ShowHeader="True" ShowSelectButton="True" />
<asp:TemplateField HeaderText="Admno" SortExpression="account">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("admno") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Admno" runat="server" Text='<%# Bind("admno") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Student Name" SortExpression="Name" />
<asp:TemplateField HeaderText="Class">
<ItemTemplate>
<asp:DropDownList ID="ddlCLASS" runat="server" Height="22px" Width="74px">
</asp:DropDownList>
<asp:Label ID="lblCategory2" runat="server" Text='<%# Eval("Class") %>' Visible="False"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Stream">
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlStream" runat="server" AutoPostBack="True" Height="21px" OnSelectedIndexChanged="ddlStream_SelectedIndexChanged" Width="98px">
</asp:DropDownList>
<asp:Label ID="lblCategory3" runat="server" Text='<%# Eval("Stream") %>' Visible="False"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlStream" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Type">
<ItemTemplate>
<asp:DropDownList ID="ddlSTDTYPE" runat="server" Height="21px" Width="87px">
</asp:DropDownList>
<asp:Label ID="lblCategory" runat="server" Text='<%# Eval("STDTYPE") %>' Visible="False"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sex">
<ItemTemplate>
<asp:DropDownList ID="ddlSex" runat="server">
</asp:DropDownList>
<asp:Label ID="lblCategory4" runat="server" Text='<%# Eval("Sex") %>' Visible="False"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rclass">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("rclass") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Rclass" runat="server" Text='<%# Bind("rclass") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Colour" SortExpression="House">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("House") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="Coloursd" runat="server" Text='<%# Bind("House") %>'></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="StudentGrid" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ACNOS" HeaderText="ACNOS" SortExpression="ACNOS" />
<asp:CommandField HeaderText="View Payment Details" SelectText="PayDetails" ShowSelectButton="True" />
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td colspan="5">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>