You must Sign In to post a response.
  • Category: .NET

    How to change my images dynamically with out rebuilding appliction

    i have apage named separate .aspx images related to sys date should slide its working fine but continuously not working when iset my sysdate to 24-08-2015 and execute my application images related to sysdate sliding its ok but when i change my sysdate to 25-08-2015 images related to this datenot sliding only images of 24-08-2015 are sliding if i stop again run my application then it works fine images related to 25-08-2015 are sliding below is my code any body see where my problem is


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;



    public partial class separate : System.Web.UI.Page
    {
    static DataTable dt;
    static int TotalRecords, CurrentRecord;
    protected void Page_Load(object sender, EventArgs e)
    {




    //Repeater1.DataSource =GetEvents();
    ////Repeater1.DataBind();
    if (!Page.IsPostBack)
    {

    string sqlconstr = "Data Source=HOME;Initial Catalog=Registration;Integrated Security=True";
    SqlConnection con = new SqlConnection(sqlconstr);
    SqlDataAdapter sqlda = new SqlDataAdapter("select * from imagepath where CurrentDate is NULL union ALL SELECT * FROM imagepath WHERE month(CurrentDate) =month(CURRENT_TIMESTAMP)And day(CurrentDate) = day(CURRENT_TIMESTAMP)", con);
    //SqlDataAdapter sqlda = new SqlDataAdapter("select * from imagepath where CurrentDate is NULL union ALL select * from imagepath where convert(varchar(20), CurrentDate,101) = convert(varchar(20),getdate, 101)", con);
    dt = new DataTable();
    sqlda.Fill(dt);
    TotalRecords = dt.Rows.Count;
    Image1.ImageUrl = "~/Upload/" + dt.Rows[0]["ImageName"].ToString();

    //Response.Redirect("uploadsite.aspx");
    //SqlDataAdapter da1 = new SqlDataAdapter("select ImageName from imagepath where convert(varchar(20), CurrentDate, 101) = convert(varchar(20), getdate(), 101)", sqlconstr);
    DataSet ds1 = new DataSet();
    SqlDataAdapter da1 = new SqlDataAdapter("select ImageName from imagepath WHERE month(CurrentDate) =month(CURRENT_TIMESTAMP)And day(CurrentDate) = day(CURRENT_TIMESTAMP)", sqlconstr);
    da1.Fill(ds1, "imagepath");


    string s1 = string.Empty;

    if (ds1.Tables["imagepath"].Rows.Count > 0)
    {

    s1 += " Happy Birthday ";
    s1 += ds1.Tables["imagepath"].Rows[0][0].ToString();
    }
    s1 += "      ";
    if (ds1.Tables["imagepath"].Rows.Count > 1)
    {
    s1 += " HappyBirthday ";
    s1 += "      ";


    s1 += ds1.Tables["imagepath"].Rows[1][0].ToString();
    }
    s1 += "      ";
    if (ds1.Tables["imagepath"].Rows.Count > 2)
    {
    s1 += " HappyBirthday ";
    s1 += "      ";

    s1 += ds1.Tables["imagepath"].Rows[2][0].ToString();
    }
    s1 += "      ";
    if (ds1.Tables["imagepath"].Rows.Count > 3)
    {
    s1 += " HappyBirthday ";
    s1 += "      ";

    s1 += ds1.Tables["imagepath"].Rows[3][0].ToString();
    }

    lt1.Text = s1.ToString();


    }

    }
    // string sqlconstr = "Data Source=HOME;Initial Catalog=Registration;Integrated Security=True";


    protected void Timer11_Tick(object sender, EventArgs e)
    {
    CurrentRecord++;
    if (CurrentRecord == TotalRecords)
    {
    CurrentRecord = 0;

    }
    Image1.ImageUrl = "~/Upload/" + dt.Rows[CurrentRecord]["newimagepath"].ToString();
    // Image1.ImageUrl = "~/Upload/" + dt.Rows[CurrentRecord]["newimagepath"].ToString();
    //Image1.ImageUrl = @"C:\Users\admin\Documents\Visual Studio 2012\WebSites\uploadsite\Upload\";
    }

    }
  • #761800

    Hi

    After you entering the new date the event is not firing as postback.
    Make the autopostback true for the control in which you are entering the date.
    As you are writing the logic part in pageload it is taking only the first entered date.
    And also you are checking
    if (!Page.IsPostBack)
    {

    }
    This will only execute your first request.

    Regards

    Sridhar Thota.
    If you learnt from defeat..
    You haven't really lost..


    Sridhar Thota.
    Editor: DNS Forum.

  • #761809
    1. Check whether you are getting the records from the database.
    2. Are you getting the correct records from theDB.

    If any of the above not happening we have to take a look in db side. Otherwise we have to take a look of your logic used in the UI side.

    By Nathan
    Direction is important than speed

  • #761837

    Hi
    velin

    First you check your database corresponding Date records is have or not then run your select query from your sql server then you come to execute c# code If you have records in your sql server means then you will got output then when the records have change your process code


    check records is have or not use this code


    if(dt.Rows.Count>0)
    {
    // Record have
    }
    else
    {
    // Record Not have
    }


    then you go to c# why not come checking your code.


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761839

    Hi
    Velin

    in Your query this

    when iset my sysdate to 24-08-2015

    But in your query this


    select ImageName from imagepath WHERE month(CurrentDate) =month(CURRENT_TIMESTAMP)And day(CurrentDate) = day(CURRENT_TIMESTAMP


    now in your system date 24-08-2015 so records have so coming

    then after you change 25-08-2015

    But your current date is 24-08-2015 so how it will come?

    Your month and dat query this


    month(CURRENT_TIMESTAMP)And day(CurrentDate) = day(CURRENT_TIMESTAMP


    so your query does not match the current date

    because your system date is 24-08-2015

    so you try to change date in your pc or

    try to insert equal date records from your system date Records it will be come try and let me know.

    I will give another solution.


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments