Page 3 of 3 FirstFirst 123
Results 81 to 108 of 108

Thread: Constructive Criticism

  1. #81
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Constructive Criticism

    Quote Originally Posted by mendhak View Post
    You need to call myScope.Complete() just before the End Using. That commits it. If you don't call it, it will rollback.

    using(TransactionScope scope = new TransactionScope())
    {
    //blah blah
    //blah blah blah blah



    scope.Complete();
    }
    But the problem she is facing is just the opposite. Means whether scope.Complete is called or not, transaction is always committed.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  2. #82

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Mend, thank again but when i tried to use Transaction i did used the Complete() method at the end of the statement it just doesn't seem to work, and i didn't really had any success with the CTRL + DOT thing, nothing happen :|, but i did check for the trace method namespace and its indeed "System.Web" but for some reason it just doesn't seem to work on that page.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  3. #83
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Constructive Criticism

    If you've mentioned it, I've forgotten - what version of Visual Studio are you running? Is it the VS 2008 Crippled Edition?

    This class that you're attempting this code in - is it in App_Code or another project or somewhere else?

  4. #84
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Constructive Criticism

    Show your Transaction code.

  5. #85

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    I already remove that part of the code and as i said i decided to use MySql built in Transactions, this code is part of my Data access layer and it's in a Class library i created as told earlier in this thread..

    and last time i fired visual studio i didn't saw nothing about "Crippled Edition" but i think i saw some text saying something like "will run only when open by the hands of a genius"

    no, seriously i have VS2008 pro edition :B
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  6. #86
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Constructive Criticism

    Hmm... in that case, either pay for my flight over there, or have a look at your references in that class library. Try adding a reference to System.Web.dll. Then do the Ctrl+. thing.

  7. #87

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Ok, things are going really well, but i'm facing this problem now, How do i bind list of <some class> to FormView Or GridView? i tried to assign list of class to a formview, there was no errors but nothing was shown on the screen either, how do i connect between the forview (or gridview) controls to the class properties ?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  8. #88
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Constructive Criticism

    In a gridview, for example, you can bind the column to a property. So if in your custom class you have a property called "JuiceType", you'd set that as the DataField in a BoundColumn in the gridview.

  9. #89

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Thank you for the answer and with formview i shoult set it at the DataBinding event?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  10. #90

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Ok so in my formview, i have textbox and i need the text will contain one of my class properties ... i can do it like that:

    Code:
    <asp:TextBox ID="txbCountryEnglishName" text='<&#37;# Eval("CountryName") %>'  runat="server" ></asp:TextBox>
    but as i been told, inline code is not a good practice, how could i set it without using inline code?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  11. #91
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    Hey,

    Use the FindControl method in the DataBound Event of the FormView:

    http://msdn.microsoft.com/en-us/libr...databound.aspx

    Gary

  12. #92

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    i already know how to find the control... the problem is how to connect the properties of the class to the controls of the formview without using inline...
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  13. #93
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    Hey,

    Assuming you have set the DataItem of the FormView to an instance of your custom class, you should be able to do something similar to the following:

    http://msdn.microsoft.com/en-us/libr....dataitem.aspx

    In your case, you are not going to have a DataRowView object, you will have an instance of your custom class.

    Hope that helps!!

    Gary

  14. #94

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Yes i think that's what i need, i will get back to that once i'll finish my current work, thanks a lot Gary!
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  15. #95
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    No probs. Let me know how you get on.

    Gary

  16. #96

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Hi again,

    look I just can't make this to work, I'll try to show you some of the code:
    Code:
     // Getting selected country ID
            int CountryID = Convert.ToInt32(ddlSelectCountry.GetCountrySelectedValue);
            // Getting list of regions by the country id from BLL --> DAL
            List<Regions> lstRegions = regions.GetRegionList(CountryID);
            // setting the panel visibility that contain the input of creating new region to false or true
            pnlAddNewRegion.Visible = regions.AddNewRegionPanelStatus(CountryID);
            // setting the form view datasource as the list of regions that just been created
            frvCountriesRegions.DataSource = lstRegions;
            frvCountriesRegions.DataBind();
    now i have this form view EditTemplate :

    Code:
     <asp:FormView ID="frvCountriesRegions" runat="server"
                                         DefaultMode ="Edit">
                                            <EditItemTemplate>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <asp:Label ID="lblRegionID" runat="server" ></asp:Label>
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txbRegionName" runat="server"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EditItemTemplate>
                                        </asp:FormView>
    the Regions class has the properties: RecordID, region_name, i need to somehow bind these two properties to the Label and the textbox... it's very easy to with inline code, but i really don't want to go this way...
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  17. #97
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    Hey,

    Try something like this (note I have made up something called Region, you would need to change it to suit your own class):

    Code:
           protected void frvCountriesRegions_DataBound(object sender, EventArgs e)
            {
                Region tempRegion = (Region)frvCountriesRegions.DataItem;
    
                Label tempLabel = (Label)frvCountriesRegions.FindControl("lblRegionID");
                tempLabel.Text = tempRegion.RecordID.ToString();
    
                TextBox tempTextBox = (TextBox)frvCountriesRegions.FindControl("txbRegionName");
                tempTextBox.Text = tempRegion.RegionName;
            }
    Gary

  18. #98

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    ok man, i'll play with this a bit and let you know.

    Thanks again.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  19. #99

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Hi Gary, it seems that it solved the problem!
    but from some reason i see only the first or last (i'm not sure yet) record!

    is something from the above code look funny to you?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  20. #100

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    it's only the first record...
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  21. #101

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    dang... i know what it is.. i shouldn't use the FormView, i should've used the repeater for this task :S..
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  22. #102
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    Hey,

    This is correct. A FormView is only designed to show one record:

    http://msdn.microsoft.com/en-us/libr...w_members.aspx

    You would need to edit the FormView to allow navigation to the different records in it's datasource.

    http://msdn.microsoft.com/en-us/library/ms227443.aspx

    Gary

  23. #103
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    Quote Originally Posted by motil View Post
    dang... i know what it is.. i shouldn't use the FormView, i should've used the repeater for this task :S..
    That would sound about right. I didn't point this out before, as I thought you had specifically chosen the FormView control.

    Gary

  24. #104

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    ok i converted it to the Repeater control, but it seems that the repeater does not have the DataItem property, how can i convert your above code to work with the repeater control?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  25. #105
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    You don't ask for much do you

    You should be able to get to this with something like this:

    Code:
            protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                Region tempRegion = (Region)e.Item.DataItem;
            }
    However, you have to do some additional checks in this case, i.e. the type of the Item that is being DataBound.

    Have a look here for some more information:

    http://msdn.microsoft.com/en-us/libr...databound.aspx

    Gary

  26. #106

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Thanks Gary, that did the trick


    Quote Originally Posted by gep13 View Post
    You don't ask for much do you
    Gary
    Well.. some things that looks obvious to you (like casting the repeater/formview DataItems to the regions class) can take me hours of searching, and if I can ask people with more experience then mine i don't see the problem. I have no doubt that with time things will more clearer for me. in the meantime i'll keep asking, if i'll get no answer i'll find it in the hard way.

    Thanks again for the help gary.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  27. #107
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Constructive Criticism

    Hey,

    I am just messing with you

    Yip, you will pick them up as you go, and never be afraid to ask questions.

    Gary

  28. #108

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Constructive Criticism

    Yip, I think that the hardest part in .NET is to master the way to approach items/controls

    Thanks again and see you in my next question :B
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width