DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Create control according to their data type

This is a discussion on Create control according to their data type within the .Net Development forums, part of the Programming & Scripting category; hi actually problem is with commented line.if i comment that line in that case no error.what i m missing? // ...

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

  #21  
Old January 21st, 2009, 01:27 PM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

hi actually problem is with commented line.if i comment that line in that case no error.what i m missing?
// objPds.CurrentPageIndex = CurrentPage - 1;

Code:
public partial class ConfigurationTool_EditPackage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!string.IsNullOrEmpty(Request.Form["MemberID"]))
        //{

            PackageList dd = PackageListBL.GetExtraInfo(121);

            if (dd != null)
            {

                PagedDataSource objPds = new  PagedDataSource();
                objPds.DataSource = dd;
                objPds.AllowPaging = true;
                objPds.PageSize = 5;
               // objPds.CurrentPageIndex = CurrentPage - 1;
                rptExtraInfo.DataSource = objPds;
                rptExtraInfo.DataBind();
                
            }
            else
            {


                rptExtraInfo.DataBind();
            }
        }
    //}
    public int CurrentPage
    {
        get
        {
            // look for current page in ViewState
            object o = this.ViewState["_CurrentPage"];
            if (o == null)
                return 0; // default page index of 0
            else
                return (int)o;
        }

        set
        {
            this.ViewState["_CurrentPage"] = value;
        }
    } 
}
__________________
Love is physical attraction and mental destruction
Reply With Quote
  #22  
Old January 21st, 2009, 01:49 PM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,347
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default

Perhaps your CurrentPage is finding nothing in ViewState and returning 0.

Then the CurrentPageIndex would be set to 0 - 1 = -1 which would throw an error.
__________________
Join the folding team
Reply With Quote
  #23  
Old January 21st, 2009, 03:33 PM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

but i think ViewState["_CurrentPage"] is default page level property.so what to do for this?
Reply With Quote
  #24  
Old January 21st, 2009, 03:39 PM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

i think this
Code:
objPds.CurrentPageIndex = CurrentPage - 1;
should be
Code:
objPds.CurrentPageIndex = CurrentPage;
Reply With Quote
  #25  
Old January 22nd, 2009, 07:05 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

hi
Thank u so much RR about your help so far.now my paging stuff with repeater is fine now problem is to retaim values of page.
as your know at each page i have form control likes text box ,dropdown .so when user filled all these values at first page and after clicking next go to next page and filled data their also and agian back to previous page the data at this page being lost.

how to retain these values.
Reply With Quote
  #26  
Old January 22nd, 2009, 07:27 AM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,347
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default

Could you save the values in a session when it moves to the next page and then retrieve them from the session when it moves back?
Reply With Quote
  #27  
Old January 22nd, 2009, 07:35 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

some sort of example would be appreciated about session.

any other way if not willing to use session.
Reply With Quote
  #28  
Old January 22nd, 2009, 07:49 AM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,347
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default

To add items to a session variable, use something like:-
Code:
HttpContext.Current.Session.Contents.Add("varName",varValue)
And to retrieve:-
Code:
Dim myValue as String = HttpContext.Current.Session.Contents.Item("varName")
I believe you can manually add items to the viewstate to keep their values, although I've not done this before....I guess you could also save the details in a database...

Maybe someone else might have a better solution...
Reply With Quote
  #29  
Old January 22nd, 2009, 08:00 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

once data filling has done in pages then user will submit .after submit i will save that data into database.

but problem is i m using paging so during page navigation i m not able to retain values.

still i m not clear with your example of session??
Reply With Quote
  #30  
Old January 22nd, 2009, 08:03 AM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,347
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default

Oh...I see what you mean now....

Hmmm...not sure...I've not used paging before...Will have to have a think about that...
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Create/Print Form data Rebelle ASP Development 5 December 10th, 2008 10:25 AM
Binding data to the RadioButtonList Control Shem .Net Development 2 December 3rd, 2008 02:42 AM
The data source 'ObjectDataSource1' does not support sorting with IEnumerable data Shem .Net Development 5 June 25th, 2008 08:07 AM
Data Type Mismatch in Criteria Expression alansidman Microsoft Access 1 April 9th, 2008 04:33 PM
[Error] Type mismatch: HTMLEncode Rebelle ASP Development 20 March 28th, 2008 09:30 AM


All times are GMT -4. The time now is 10:55 AM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2