Passing session object from login page to next page

Category: ASP.NET Questions    |    3 views    |    Add a Comment
how can we use the session object in asp.net

Share/Save/Bookmark

 

how to getting one txet value

Category: ASP.NET Questions    |    0 views    |    Add a Comment
first just read my aspx&aspx.cs codes then repaly me
aspx.cs code:

namespace ReceiptsEntryPro
{
    public partial class Groups : System.Web.UI.Page
    {
        RecieptBusiness objbs = new RecieptBusiness();
        string strid;
        
        
        protected void Page_Load(object sender, EventArgs e)
        {

            GlidMax();

            ItemsGet();

          //repGroups.DataSource = dsrep;
          //repGroups.DataBind();

        }

        

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strGroupName;
            string strGroupId;
            string obsolute;
            if (txtGroupName.Text.ToString() == "")
            {
                lblerror.Text = "Please Enter The Value For GroupName";
                lblerror.ForeColor = System.Drawing.Color.Red;
                lblerror.Font.Bold = true;
                lblerror.Font.Size = 10;
            }
            else
            {
                strGroupId = txtGrouid.Text.ToString();
                strGroupName = txtGroupName.Text.ToString();
                obsolute = "N";
                objbs.InsertGroupsData(strGroupId, strGroupName, obsolute);
                ItemsGet();
                LblMessage.Text = "Inserted SuccessFully";
                LblMessage.Font.Bold = true;
                LblMessage.ForeColor = System.Drawing.Color.Green;                
                GlidMax();
                txtGroupName.Text = "";
            }

        }

        protected void btnEditClick(object sender, System.EventArgs e)
        {

            ImageButton btnFindEdit = (ImageButton)sender;
            Label lblid = btnFindEdit.Parent.FindControl("lblgouid") as Label;
            Label lblname = btnFindEdit.Parent.FindControl("lblgouname") as Label;
            txtGrouid.Text = lblid.Text.ToString();
            txtGroupName.Text = lblname.Text.ToString();
            
        }
        protected void btnDeleteClick(object sender, System.EventArgs e)
        {

            ImageButton btnFindEdit = (ImageButton)sender;
            Label lblid1 = btnFindEdit.Parent.FindControl("lblgouid") as Label;
            string strlblid = lblid1.Text.ToString();
            objbs.GroupsDelete(strlblid);
            ItemsGet();
            LblMessage.Text = "Deleted SuccessFully";
            LblMessage.ForeColor = System.Drawing.Color.Green;
            txtGroupName.Text = "";
           
            GlidMax();
        }

        protected void repGroups_ItemCommand(object source, RepeaterCommandEventArgs e)
        {

        }

        protected void btnprev_Click(object sender, EventArgs e)
        {
            // Set viewstate variable to the previous page
            CurrentPage -= 1;

            // Reload control
            ItemsGet();

        }

        protected void btnnext_Click(object sender, EventArgs e)
        {
            // Set viewstate variable to the next page
            CurrentPage += 1;

            // Reload control
            ItemsGet();

        }
        public void ItemsGet()
        {
            DataSet dsrep = objbs.loadrepGroup();


            // Populate the repeater control with the Items DataSet
            PagedDataSource objPds = new PagedDataSource();
            objPds.DataSource = dsrep.Tables[0].DefaultView;
            objPds.AllowPaging = true;
            objPds.PageSize = 10;

            objPds.CurrentPageIndex = CurrentPage;

            //lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
            //    + objPds.PageCount.ToString();

            btnprev.Enabled = !objPds.IsFirstPage;
            btnnext.Enabled = !objPds.IsLastPage;

            repGroups.DataSource = objPds;
            repGroups.DataBind();
        }
        public int CurrentPage
        {
            get
            {
                // look for current page in ViewState
                object o = this.ViewState["_CurrentPage"];
                if (o == null)
                    return 0;        // default to showing the first page
                else
                    return (int)o;
            }

            set
            {
                this.ViewState["_CurrentPage"] = value;
            }
        }
        public void GlidMax()
        {
            DataSet ds = objbs.loadGroup();
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    strid = dr["glid"].ToString();

                }
            }
            int intid = Convert.ToInt16(strid);
            intid = intid + 1;
            string strconid = Convert.ToString(intid);
            strconid = "GL-" + strconid;
            txtGrouid.Text = strconid;
        }

        protected void btnClear_Click(object sender, EventArgs e)
        {
            txtGroupName.Text = "";

        }
    }
}
aspx code: 
<%@ Page Language="C#" MasterPageFile="~/Entry.Master" AutoEventWireup="true" Codebehind="Groups.aspx.cs"
    Inherits="ReceiptsEntryPro.Groups" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tblCntentGroups" cellpadding="0" cellspacing="0" width="100%" runat="server">
        <tr>
            <td>
                <asp:Label ID="lblerror" Text="" runat="server"></asp:Label>
                <asp:Label ID="LblMessage" Text ="" runat ="server" ></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                <div class="HdrTitle">
                    <asp:Button ID="btnSave" Text="Save" runat="server" CssClass="btnnormal" Width="50px"
                        OnClick="btnSave_Click" />
                    <asp:Button ID="btnSamle" Text="Sample" runat="server" CssClass="btnnormal" Width="50px" />
                    <asp:Button ID="btnClear" Text="Clear" runat="server" CssClass="btnNormal" Width="50px" />
                    <asp:Button ID="btnPrint" Text="print" runat="server" CssClass="btnNormal" Width="50px" />
                    <asp:Button ID="btnExit" Text="Exit" runat="server" CssClass="btnNormal" Width="50px" />
                </div>
            </td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td style="height: 24px">
                <asp:Label ID="lblGroupid" Text="Groupid" runat="server"  Width="100px"></asp:Label>
                <asp:TextBox ID="txtGrouid" Enabled ="false"  runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lblGroupName" Text="Groupname" runat="server" Width="100px"></asp:Label>
                <asp:TextBox ID="txtGroupName" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>
    <div>
        <asp:Repeater ID="repGroups" runat="server" OnItemCommand="repGroups_ItemCommand">
            <HeaderTemplate>
                <table class="ListShort" cellpadding="0" cellspacing="0" border="1" width="100%">
                    <tr class="Header">
                        <td>
                            <asp:Label ID="lblrepGroupid" Text="GroupId" ForeColor="black" Font-Bold="true" runat="server">
                            </asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblrepGroupname" Text="GroupNmae" ForeColor="black" Font-Bold="true"
                                runat="server">
                            </asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblrepedit" Text="Edit" ForeColor="black" Font-Bold="true" runat="server">
                            </asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblrepdelete" Text="Delete" ForeColor="black" Font-Bold="true" runat="server">
                            </asp:Label>
                        </td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="DataLight">
                    <td>
                        <asp:Label ID="lblgouid" Text=’<% #DataBinder.Eval(Container.DataItem, "GLID") %>’
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblgouname" Text=’<% #DataBinder.Eval(Container.DataItem, "GLName") %>’
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnEdit" ImageUrl="" runat="server"  OnClick="btnEditClick" CommandName="Edit" />
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnDelete" ImageUrl="" runat="server" OnClientClick="javascript:return confirm(’Do you want to delete this?’);" OnClick="btnDeleteClick"  CommandName="Delete" />
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="DataDark">
                    <td>
                        <asp:Label ID="lblgouid" Text=’<% #DataBinder.Eval(Container.DataItem, "GLID") %>’
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblgouname" Text=’<% #DataBinder.Eval(Container.DataItem, "GLName") %>’
                            runat="server">
                        </asp:Label>
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnEdit" ImageUrl="" runat="server" OnClick="btnEditClick"
                            CommandName="Edit" />
                    </td>
                    <td>
                        <asp:ImageButton ID="imgbtnDelete" ImageUrl="" runat="server" OnClientClick="javascript:return confirm(’Do you want to delete this?’);" OnClick="btnDeleteClick" CommandName="Delete" />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <asp:Button ID="btnprev" Text="<<" Font-Bold="true" runat="server" OnClick="btnprev_Click" />
    <asp:Button ID="btnnext" Text=">>" Font-Bold="true" runat="server" OnClick="btnnext_Click" />
</asp:Content>

my problem is i click edit image in running time it refrrsh the page then it givepage load
txtGrouid but i want edit image selected rows glid=txtGrouid how i do it pls replay me

Share/Save/Bookmark

 

binary to decimal in c++

Category: C++ Questions    |    4 views    |    Add a Comment
hello

i hope you can help me :icon_question:

i just want to know how to code binary value to decimal value using c++

im willing to wait for your response :)

thanks a lot

godspeed

Share/Save/Bookmark

 

what is wrong with my enum

Category: C++ Questions    |    1 views    |    Add a Comment
I am working on the code that reads an enum. It seems to point to an address instead
Here is the code

thanks for any help

//////////////////////////////////////////////////////////////////
//contribtor.h
#ifndef        CONTRIBUTOR_H 
#define        CONTRIBUTOR_H
#include <iostream>
#include <string>
using namespace std;
//================================================================
//CONSTANT DEFINITIONS

enum Gender {Male=0, Female, None};

class Contributor
{
friend ostream &operator <<(ostream & Out,Contributor &InContrib);
friend istream &operator >>(istream & In, Contributor &InContrib);

public:        
        Contributor();
        Contributor(string InContrib, double Contribution, Gender Sex, int IDKey);
        Contributor(Contributor &CCContrib);
        ~Contributor(){cout<<"Test #1b - This is the Contributor destructor. "<<endl;}

/////Overloaded Operators
        Contributor &operator=(const Contributor & RtSide);
        bool operator <(const Contributor & RtSide);
        bool operator >(const Contributor & RtSide);
         bool operator ==(const Contributor & RtSide);
        bool operator !=(const Contributor & RtSide);
                
private:
        string InContrib;
        double Contribution;
        Gender Sex;
        int IDKey;
};

#endif
////////////////////////////////////////////////////////////////
//contributor. cpp

#include <iostream>
#include <string>
#include <iomanip>
#include "Contributor.h"
using namespace std;

///c-tor implementation 
Contributor::Contributor()
{        Contribution = 0.0f; 
        Sex = None;
        IDKey = 0; 
        cout<<endl<<"Test #1a - This is the default constructor"<<endl;
}
//copy C-tor

Contributor::Contributor(string InContrib, double Contribution, Gender Sex, int IDKey)
{
        InContrib=InContrib;
        Contribution=Contribution;
        Sex=Sex;
        IDKey=IDKey;
        /*cout<<"The Contributor is "<<InContrib<<endl; 
        cout<<InContrib <<"’s Contribution is "<<Contribution<<endl; 
        cout<<InContrib <<"’s Gender is "<<Sex<<endl;
*/}
Contributor::Contributor(Contributor &CCContrib)
{
        //cout<<endl<<"Test #3 - This is the Copy c-tor"<<endl;
        InContrib = CCContrib.InContrib;
        Contribution= CCContrib.Contribution;
        Sex = CCContrib.Sex;
        IDKey = CCContrib.IDKey;
        cout<<CCContrib<<endl;
}
ostream &operator <<(ostream & Out,Contributor &InContrib)
        {
                //Out<<endl<<"Name of the Contributor? " <<endl;
                Out<<"Name: " <<InContrib.InContrib <<endl;
                Out<<"Contribution: "<<InContrib.Contribution<<endl; 
                Out<<"ID Number: " <<InContrib.IDKey<<endl;
                Out<<"Gender: ";  
                        switch (InContrib.Sex)
                        {
                                case Male: cout<< "Male"; break;
                                case Female: cout<< "Female"; break;
                                //case default: cout<< "None"; break;
                                /*case 1: Out<<" Male ";break; 
                                case 2: Out<<" Female "; break;*/
                                default: Out<<"None ";break;
                     }
                Out<<endl<<endl<<endl;
                return Out; 
        }
istream &operator >> (istream &In,Contributor &InContrib)
        {

                Gender Sex;
                int IDKey;
                double Contribution;
                int SelSex = 0;//selection of gender
                In.clear();
                In.ignore(In.rdbuf()->in_avail(), ‘\n’); 
                cout<<"\tEnter Contirbutors Name: ";
                getline(In,InContrib.InContrib); 
                cout<<InContrib<<endl;

                cout<<"\tEnter the amount of "<<InContrib.InContrib<<"’s contribution ";
                In>>InContrib.Contribution; 
                cout<<Contribution<<endl;
                
                cout<<"\tNow Enter an ID# for "<<InContrib.InContrib<<" ";
                In>>InContrib.IDKey;
                cout<<IDKey<<endl;
                
                cout<<"\twhat is "<<InContrib.InContrib<<"’s Gender? "<<endl;
                cout<<"\t1. Male. \n\t2. Female \n\t3. None\n\n";
                In >> SelSex;
                        switch(SelSex)
                        {
                                case 1: InContrib.Sex = Male; break;
                                case 2: InContrib.Sex = Female; break;
                                case 3: InContrib.Sex = None; break;
                        }
                return In;
                cout<<Sex<<endl;
        }
Contributor &Contributor::operator = (const Contributor & RtSide)
{
        if(this != &RtSide)
        {
                InContrib = RtSide.InContrib;
                Contribution = RtSide.Contribution;
                Sex = RtSide.Sex;
                IDKey = RtSide.IDKey;
        }        
        return *this;
}
bool Contributor::operator <(const Contributor & RtSide)
        {
                return (InContrib <RtSide.InContrib); 
        }

bool Contributor::operator >(const Contributor & RtSide)
        {
                return (InContrib <RtSide.InContrib);
        }        

bool Contributor::operator ==(const Contributor & RtSide)
        {
                return ((InContrib == RtSide.InContrib)&&(Contribution==RtSide.Contribution)&&(Sex== RtSide.Sex));
        }
bool Contributor::operator !=(const Contributor & RtSide)
        {
                return((InContrib != RtSide.InContrib)||(Contribution!=RtSide.Contribution)||(Sex != RtSide.Sex));
        }
////////////////////////////////////////////////////////////////////////////////
//main driver

#include <iostream> 
#include <string> 
#include "Contributor.h"

using namespace std;        
//============================================================================
//                                                        FUNCTION PROTOTYPES   
//*****************************************************************************
//                    BEGINNING OF MAIN PROGRAM CODE
//****************************************************************************

int main()
{
//Test 1 and 5
        Contributor myObj1;
//Test 2
        Contributor myObj2("phillip",159.75,None,23);
//Test 3
        Contributor myObj3(myObj2);// this uses the copy c-tor to make myObj3 same as myObj2 
        cout<<endl<<"MyObj4….";
        Contributor myObj4("Hank ",4159.56,None,43);
        cout<<endl<<"MyObj5…. ";
        Contributor myObj5("Peggy",1549.34,Female,24);
        cout<<endl<<"MyObj6….";
        Contributor myObj6("Company one",1459.12,None,22);
//Test 4
        cout<< "Test #4 -  The Assignment of myObj1=myObj3" <<endl; 
        myObj1= myObj3; //now all myObjs are myObj2
        cout<<myObj1;
//Test 6
        cout<<"Test #6 - The >> operator " <<endl<<endl;
        cin >> myObj1;
        cout<<myObj1;
//Test 7 
        cout<<"Test #7 - The < operator " <<endl<<endl;
        cout<<"\tmyOjb5 < myObj6 = "<<boolalpha<<(myObj5<myObj6)<<endl<<endl;
//Test 8 
        cout<<"Test #8 - The > operator "<<endl<<endl;
        cout<<"\tmyObj4 > myObj6 = "<<boolalpha<<(myObj4>myObj6)<<endl<<endl; 
        
//Test 9 
        cout<<"Test #9 - The == Operator\n\n";
        cout<<"\tmyObj1==myObj3 = "<<boolalpha<<(myObj1 == myObj3)<<endl<<endl;
        cout<<"\tmyObj1==myObj6 = "<<boolalpha<<(myObj3 == myObj6)<<endl<<endl;

//Test 10 
        cout<<"Test #10 - The != Operator\n\n";
        cout<<"\tmyObj5==myObj3 = "<<boolalpha<<(myObj5 != myObj3)<<endl<<endl;
        cout<<"\tmyObj1==myObj3 = "<<boolalpha<<(myObj1 != myObj3)<<endl<<endl;

cout <<myObj1;

return 0;
}

Share/Save/Bookmark