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; with above problem now i want to save that values in database also.so any direction is appreciated....

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

  #31  
Old January 22nd, 2009, 08:08 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

with above problem now i want to save that values in database also.so any direction is appreciated.
__________________
Love is physical attraction and mental destruction
Reply With Quote
  #32  
Old January 22nd, 2009, 08:55 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,915
Blog Entries: 7
Rep Power: 13
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Here's how I handle the paging:

First, create a property:
Code:
public int CurrentPage { 
    get { 
        if (string.IsNullOrEmpty(ViewState("currentPage"))) { 
            return 1; 
        } 
        else { 
            return (int)ViewState("currentPage"); 
        } 
    } 
    set { ViewState("currentPage") = value; } 
}
Then, create your PagedDataSource and set the CurrentPageIndex:
Code:
{ 
    PagedDataSource pgdSource = new PagedDataSource(); 
    
    { 
        pgdSource.DataSource = yourdatasource; 
        pgdSource.AllowPaging = true; 
        pgdSource.PageSize = 20; 
        pgdSource.CurrentPageIndex = (CurrentPage - 1); 
    } 
}
Then, you change the CurrentPage property on the event you want to change the page. For example, if your paging was displayed in a dropdown list, use the DropDownList.SelectedIndexChanged event to set CurrentPage equal to the selected value.
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
  #33  
Old January 22nd, 2009, 09:02 AM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,312
Blog Entries: 5
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

I believe the paging is sorted J.

As I understand it, the issue is, if you change a textbox or dropdown on page 1 and then go to page 2, when you go back to page 1, the new details you entered aren't saved. It's these changes guddu needs to keep.

I would assume the best way would be to update the db when the page changes?

Comments on this post
sbenj69 agrees: Random Rep Fest!!
__________________
Join the folding team
Reply With Quote
  #34  
Old January 22nd, 2009, 09:06 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,915
Blog Entries: 7
Rep Power: 13
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Then the values and ID's of each control would have to be stored in viewstate as well. Then, when a page is clicked, during that event you would have to check if there is a value for the id in viewstate and then set the value of the control to the value in viewstate. The same concept is used here with CheckBoxes: Maintaining Checkbox State in a Listview
Reply With Quote
  #35  
Old January 22nd, 2009, 09:33 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

hey can give me link which used c# for this purpose.
Reply With Quote
  #36  
Old January 22nd, 2009, 09:38 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,915
Blog Entries: 7
Rep Power: 13
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Quote:
Originally Posted by guddu View Post
hey can give me link which used c# for this purpose.
Just use the converter: Convert VB.NET to C# - A free code conversion tool - developer Fusion - Visual Basic, C# Programming, ASP.NET, .NET Framework and Java Tutorials
Reply With Quote
  #37  
Old January 22nd, 2009, 09:49 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

huh.during conversion i m getting error for below code
line 1 col 11: invalid NonModuleDeclaration
Code:
Protected Sub AddRowstoIDList()
    ' Loop through all the current items in the Listview
    For Each lvi As ListViewDataItem In ListView1.Items
        ' Find the checkbox in each row
        Dim chkSelect As CheckBox = CType(lvi.FindControl("chkSelect"), CheckBox)
        ' If the checkbox is ticked then add the corresponding ID to our private list
        If (Not (chkSelect) Is Nothing) Then
            ' Get the ID from the datakeynames property
                Dim ID As Integer = 
            Convert.ToInt32(Listview1.DataKeys(lvi.DisplayIndex).Value)
            If (chkSelect.Checked AndAlso Not Me.IDs.Contains(ID)) Then
                ' Add the ID to our list
                Me.IDs.Add(ID)
            ElseIf (Not chkSelect.Checked AndAlso Me.IDs.Contains(ID)) Then
                ' Not checked - remove the ID from our list
                Me.IDs.Remove(ID)
            End If
        End If
    Next
End Sub
Reply With Quote
  #38  
Old January 22nd, 2009, 10:02 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,915
Blog Entries: 7
Rep Power: 13
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

I'm not sure why it's not converting, but just take the concept and see what you can come up with.
Reply With Quote
  #39  
Old January 22nd, 2009, 10:11 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

can u tell me how to convert this line
Code:
' Get the ID from the datakeynames property
                Dim ID As Integer =   Convert.ToInt32(Listview1.DataKeys(lvi.DisplayIndex).Value)
for my repeater control???
Reply With Quote
  #40  
Old January 22nd, 2009, 10:29 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,915
Blog Entries: 7
Rep Power: 13
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Code:
int ID = Convert.ToInt32(Listview1.DataKeys(lvi.DisplayIndex).Value);
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 02:04 AM.


Copyright ©2008-2009, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2