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

    How to drop table from code behind file if session expire?

    I am creating table in actual database,base on sessionid of user in button1 click event and adding record into it and in button2 click event, I doing some processing and finally droping that table.It is working fine.

    But if user does not click on button2 or move to another page or session expire or user close browser,in above secanario my table exist as it as in database.How can I drop that table?

    I can't create temp table.If my sql connection closes temp table automatically get dropped.Here I am fetching record from grid that have paging.If user select some record from page one and click on button1,table get created and record get added into that table,when user move to second page and select record,that record get added into table.
  • #762505
    Hi Pinky,

    The scenario which you have that is a good one, why you are dropping tables.? that too you are giving to user to drop a table. Is this good way to do..? I don't think so, on what base you people are selecting this requirement, and that too based on session expiration...

    I request you to please provide full details of the same, if the requirement is drop the tables ( May be older and not used at present ). In that case drop tables in a single shot using some SQL Scripts, don't give to user to drop those, that is not good.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762509
    Thanks naveensanagasetti for ur reply.I am showing record in grid(contain checkbox as first column) that has paging.If I select record and move to second page selected record from first get unchecked.Shall I make enable viewstate?What will happen?Can I able to fetch all record(id) which are selected from all pages of grid at a time in button click event?
    foreach (GridViewRow rowItem in Gridview1.Rows)
    {
    }
    above code give me record from current page not from all table?

  • #762512
    Hi

    You can selected records track means in gridview try this code for c#

    in RadioButton Event



    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
    {
    for (int i = 0; i < ddsales.Rows.Count; i++)
    {
    RadioButton rb = (RadioButton)ddsales.Rows[i].Cells[0].FindControl("RadioButton1");
    if (rb.Checked == true)
    {
    Label lqtyyytno = (Label)ddsales.Rows[i].Cells[1].FindControl("lqtyyytno");
    ViewState["lotno"] = lqtyyytno.Text;
    }
    }
    }





    you can try this code and let me know if you have any issue means .

    Can you share the code then we can easily and Quick reply for your issue.

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

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

  • #762525
    Hi Pinky,

    In such cases, if you want to maintain state in multiple pages ViewState won't helpful to you, use session object instead of ViewState, we can't maintain the state in multiple pages using viewstate. So, using session we can maintain state in multiple pages until it's gets expired, if you think that after session expire I loose the data, in such cases you need to increase the session timeout as you want, default timeout for session is 20 mins.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments