Hi Guys,
I'm trying to show data from database to view without using databinder but the result not showing in view.
The query was test on Sql Server working properly but after test on Visual Studio 2012 not show the result as well.
This the view .aspx
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="col-lg-3 col-6">
<!-- small box -->
<div class="small-box bg-warning">
<div class="inner">
<h3><b><asp:Label ID="Label_Jumlah_Simpanan" runat="server" Text=""></asp:Label></b></h3>
<p>Jumlah Simpanan</p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="<%=Page.ResolveClientUrl("~/View/Simpanan.aspx")%>" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
</div>
</div>
</asp:Content>
This the code behind
public partial class Shared_Default : System.Web.UI.Page
{
string koneksi = System.Configuration.ConfigurationManager.ConnectionStrings["db_koperasiConnectionString"].ConnectionString.ToString();
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
LoadData();
}
}
private void LoadData()
{
using (SqlConnection con = new SqlConnection(koneksi))
{
using (SqlCommand cmd = new SqlCommand())
{
try
{
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select SUM(jumlah_simpanan) From tbl_simpanan";
using (SqlDataReader rdr = cmd.ExecuteReader())
{
rdr.Read();
int Row = Convert.ToInt32(rdr[0].ToString());
Label_Jumlah_Simpanan.Text = Convert.ToString(string.Format("{0:Rp 0,00.00}",Row));
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
}
Any help could be appriciate.