Dear Sir
Please help me to show the dropdown value in textbox1. please help me.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ServiceDeshboardOnline.aspx.cs" Inherits="ServiceDeshboardOnline" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Deshboard-Service Online</title>
<meta charset="utf-8" />
<meta name="viewport" content="width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 1.0, user-scalable = no" />
<%-- <meta name="viewport" content="width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 1.0, user-scalable = no" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="keywords" content="htmlcss bootstrap, multi level menu, submenu, treeview nav menu examples" />
<meta name="description" content="Bootstrap 5 navbar multilevel treeview examples for any type of project, Bootstrap 5" />--%>
<%-- Start Sweet Alert --%>
<script type="text/javascript" src='https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.min.js'> </script>
<link rel="stylesheet" href='https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.min.css' media="screen" />
<link rel="stylesheet" href='https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.css' media="screen" />
<%-- end Sweet Alert --%>
<%--<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>--%>
<script src="../Scripts/jquery-1.7.2.min.js"></script>
<link type="text/css" href="../Scripts/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
<script type="text/javascript" src="../Scripts/jquery-ui-1.8.19.custom.min.js"></script>
<%-- Start Responsive GridView --%>
<link rel="stylesheet" href="https://unpkg.com/bootstrap@5.3.2/dist/css/bootstrap.min.css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/css/footable.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/js/footable.min.js"></script>
<script type="text/javascript">
$(function () {
$('[id*=GvPropertyAllocatedList]').footable();
});
</script>
<script type="text/javascript">
$(function () {
$('[id*=GvGenAllocatedList]').footable();
});
</script>
<%-- End Responsive GridView --%>
<%-- Start Sweet Alert confirm --%>
<script type="text/javascript">
var object = { status: false, ele: null };
function ConfirmMessageOne(event) {
if (object.status) { return true; };
swal({
title: "Are You Sure ?",
text: "Save Fuel Request ⚠️ ?",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, Process",
cancelButtonColor: 'Crimson',
confirmButtonColor: 'LightSeaGreen',
closeOnConfirm: true
}).then(function () {
object.status = true;
object.ele = event;
showLoader1();
$('[id*=BtnSaveRequest').click();
});
return false;
};
</script>
<script type="text/javascript">
var object = { status: false, ele: null };
function ConfirmMessageTwo(event) {
if (object.status) { return true; };
swal({
title: "Are You Sure ?",
text: "Save Daily Log ? ⚠️",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, Process",
cancelButtonColor: 'Crimson',
confirmButtonColor: 'LightSeaGreen',
closeOnConfirm: true
}).then(function () {
object.status = true;
object.ele = event;
showLoader1();
$('[id*=BtnSaveLog').click();
});
return false;
};
</script>
<%-- End Sweet Alert confirm --%>
<%-- Start Separate Loader Start --%>
<script type="text/javascript">
function showLoader1() {
document.getElementById("loader1").style.display = 'block';
}
function showLoader2() {
document.getElementById("loader2").style.display = 'block';
}
function showLoader3() {
document.getElementById("loader3").style.display = 'block';
}
function showLoader4() {
document.getElementById("loader4").style.display = 'block';
}
</script>
<%-- End Loader End --%>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%-- Start Title Container --%>
<div class="container">
<div class="row g-0 " style="background-image: linear-gradient(to right, lightblue ,lightgreen);">
<div class="col col-12 text-center p-0 fs-3">
<asp:Label ID="Label1" runat="server" Text="Deshboard-Service"></asp:Label>
</div>
</div>
</div>
<%-- End Title Container --%>
<%-- Start Detail --%>
<div class="container mb-0 mt-0">
<asp:Panel ID="PnlDetail" runat="server">
<div class="row g-0">
<div class="col col-3 text-start bg_Entry_Color1 border border-dark">
<asp:Label ID="Label5" runat="server" Text="User Id"> </asp:Label>
</div>
<div class="col col-9 text-start bg_Entry_Color1 border border-dark">
<asp:TextBox ID="TxtUserId" CssClass="w-100" Text="" runat="server"> </asp:TextBox>
</div>
</div>
<div class="row g-0">
<div class="col col-3 text-start bg_Entry_Color1 border border-dark">
<asp:Label ID="Label2" runat="server" Text="User Name"> </asp:Label>
</div>
<div class="col col-9 text-start bg_Entry_Color1 border border-dark">
<asp:TextBox ID="TxtUserName" CssClass="w-100" Text="" runat="server"> </asp:TextBox>
</div>
</div>
<div class="row g-0">
<div class="col col-3 text-start bg_Entry_Color1 border border-dark">
<asp:Label ID="Label9" runat="server" Text="Company"> </asp:Label>
</div>
<div class="col col-9 text-start bg_Entry_Color1 border border-dark">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DdlCompany" AutoPostBack="true" runat="server">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</div>
<div class="row g-0">
<div class="col col-3 text-start bg_Entry_Color1 border border-dark">
<asp:Label ID="Label4" runat="server" ForeColor="Red" Text="Request Qty"> </asp:Label>
</div>
<div class="col col-9 text-start bg_Entry_Color1 border border-dark">
<asp:TextBox ID="TxtRequestQty" CssClass="w-75" ValidationGroup="SaveRequest" runat="server"> </asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TxtRequestQty" ErrorMessage="Enter only 0-9 numbers." ValidationGroup="SaveRequest" SetFocusOnError="true" ForeColor="Red"
ValidationExpression="^[0-9]*$"></asp:RegularExpressionValidator>
</div>
</div>
</asp:Panel>
</div>
<%-- End Request Detail --%>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
//using iTextSharp.text;
//using iTextSharp.text.html.simpleparser;
//using iTextSharp.text.pdf;
public partial class ServiceDeshboardOnline : System.Web.UI.Page
{
SqlConnection SqlCn;
SqlCommand SqlCm;
SqlDataReader SqlDr;
SqlDataAdapter SqlDa;
DataTable SqlDt;
DataSet SqlDs;
ConnectionState ConState;
static string SqlQry;
static string ConPath;
static Boolean SmtpContectionStatus;
static Boolean TransactionStatus;
static int StaffId;
static string StaffName;
static string StaffCompanyName;
static int StaffCompanyCode;
static string StaffBranchName;
static int StaffBranchCode;
static string TodayDate;
static string LoginRole;
static string LoginCode;
static string LoginName;
static int LoginId;
static string LoginEmailId;
static string LoginDivision;
static string MessageTitle;
static string SwalTitle; // Transaction
static string SwalShowMessage; // Display User Message
static string SwalMessageType; // error , info warning success
static string SwalErrorServerSide; // message capture from server side
// End SWAL Message
static Regex whitespace = new Regex(@"\s+", RegexOptions.Compiled); // Remove Space from string Check Vehicle Entry
protected void Page_Load(object sender, EventArgs e)
{
TxtUserId.Text = "101";
LoadCompanyList();
}
// End Page Load
// Start connection string
protected void ConnectionStringFunction()
{
// Start Connection String From Class
MainClass ClassObj = new MainClass(); // Class Object
//<Class> <ObjectName>= new <ClassFileName>;
MainClass.ConPathClass = ClassObj.GetConnectionForClass(); //Connection path from Class
//Define Function Return Value
//<ClassName>.<Variable>=<ClassObject>.<FunctionName()>;
MainClass.ConPathClass = MainClass.ConPathClass.ToString();
ConPath = MainClass.ConPathClass.ToString();
//End Connection String From Class
try
{
SqlCn = new SqlConnection(ConPath);
SqlCn.Open();
ConState = SqlCn.State;
SqlCn.Close();
if (ConState == ConnectionState.Closed || ConState == ConnectionState.Broken)
{
TransactionStatus = false;
}
else
{
TransactionStatus = true;
}
}
// End Try
catch (Exception ex)
{
TransactionStatus = false;
MessageTitle = "Data Base Connection Error " + ex.ToString();
}
finally
{
SqlCn.Close();
}
}
//End Connection String From Class
public void SwalErrorMessageDisplay()
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert",
"swal('" + SwalTitle + "','" + SwalShowMessage + "', '" + SwalMessageType + "' )", true);
}
// End Swal Message
protected void LoadCompanyList()
{
DdlCompany.DataSource = null;
DdlCompany.DataBind();
ConnectionStringFunction();
SqlCn = new SqlConnection(ConPath);
SqlCn.Open();
SqlQry = "select CompanyName,CompanyCode from permissioncompany where userid='" + TxtUserId.Text.Trim() + "' order by CompanyName";
SqlCm = new SqlCommand(SqlQry, SqlCn);
SqlDr = SqlCm.ExecuteReader();
DdlCompany.DataSource = SqlDr;
DdlCompany.DataTextField = "CompanyName";
DdlCompany.DataValueField = "CompanyCode";
DdlCompany.DataBind();
DdlCompany.Items.Insert(0, "SELECT");
SqlDr.Close();
SqlCn.Close();
}
// End Property Expenses Type
protected void LoadCompany1()
{
DdlCompany.DataSource = null;
DdlCompany.DataBind();
ConnectionStringFunction();
SqlCn = new SqlConnection(ConPath);
SqlCn.Open();
string constr = ConfigurationManager.ConnectionStrings["Rs4uConWeb"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("select CompanyName, convert(varchar(3), CompanyCode) as companycode from permissioncompany where userid='" + TxtUserId.Text.Trim() + "' order by CompanyName"))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
DdlCompany.DataSource = cmd.ExecuteReader();
DdlCompany.DataTextField = "CompanyName";
DdlCompany.DataValueField = "CompanyCode";
DdlCompany.DataBind();
con.Close();
}
}
//DdlCompany.Items.Insert(0, new ListItem("--Select Customer--", "0"));
//DdlCompany.Items.Insert(0, "SELECT");
}
// End Company
protected void DdlCompany_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = DdlCompany.SelectedValue;
}
}