|
-
Dec 14th, 2009, 11:45 AM
#81
Re: Constructive Criticism
 Originally Posted by mendhak
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.
-
Dec 14th, 2009, 12:50 PM
#82
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 
-
Dec 14th, 2009, 01:43 PM
#83
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?
-
Dec 14th, 2009, 01:43 PM
#84
Re: Constructive Criticism
Show your Transaction code.
-
Dec 14th, 2009, 01:59 PM
#85
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 
-
Dec 14th, 2009, 02:04 PM
#86
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.
-
Dec 16th, 2009, 05:22 PM
#87
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 
-
Dec 16th, 2009, 05:59 PM
#88
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.
-
Dec 17th, 2009, 02:23 AM
#89
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 
-
Dec 17th, 2009, 11:17 AM
#90
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='<%# 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 
-
Dec 17th, 2009, 11:22 AM
#91
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
-
Dec 17th, 2009, 11:25 AM
#92
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 
-
Dec 17th, 2009, 04:26 PM
#93
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
-
Dec 17th, 2009, 05:45 PM
#94
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 
-
Dec 18th, 2009, 02:33 AM
#95
Re: Constructive Criticism
No probs. Let me know how you get on.
Gary
-
Dec 18th, 2009, 10:05 AM
#96
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 
-
Dec 18th, 2009, 10:21 AM
#97
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
-
Dec 18th, 2009, 10:26 AM
#98
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 
-
Dec 18th, 2009, 10:56 AM
#99
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 
-
Dec 18th, 2009, 10:57 AM
#100
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 
-
Dec 18th, 2009, 10:58 AM
#101
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 
-
Dec 18th, 2009, 10:59 AM
#102
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
-
Dec 18th, 2009, 11:00 AM
#103
Re: Constructive Criticism
 Originally Posted by motil
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
-
Dec 18th, 2009, 11:16 AM
#104
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 
-
Dec 18th, 2009, 11:20 AM
#105
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
-
Dec 18th, 2009, 11:35 AM
#106
Re: Constructive Criticism
Thanks Gary, that did the trick 
 Originally Posted by gep13
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 
-
Dec 18th, 2009, 11:39 AM
#107
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
-
Dec 18th, 2009, 11:46 AM
#108
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 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|