But the problem she is facing is just the opposite. Means whether scope.Complete is called or not, transaction is always committed.
Printable View
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.
If you've mentioned it, I've forgotten - what version of Visual Studio are you running? Is it the VS 2008 Crippled Edition? :p
This class that you're attempting this code in - is it in App_Code or another project or somewhere else?
Show your Transaction code.
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" :D
no, seriously i have VS2008 pro edition :B
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.
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 ?
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.
Thank you for the answer and with formview i shoult set it at the DataBinding event?
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:
but as i been told, inline code is not a good practice, how could i set it without using inline code?Code:<asp:TextBox ID="txbCountryEnglishName" text='<%# Eval("CountryName") %>' runat="server" ></asp:TextBox>
Hey,
Use the FindControl method in the DataBound Event of the FormView:
http://msdn.microsoft.com/en-us/libr...databound.aspx
Gary
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...
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
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!
No probs. Let me know how you get on.
Gary
Hi again,
look I just can't make this to work, I'll try to show you some of the code:
now i have this form view EditTemplate :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();
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...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>
Hey,
Try something like this (note I have made up something called Region, you would need to change it to suit your own class):
GaryCode: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;
}
ok man, i'll play with this a bit and let you know.
Thanks again.
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?
it's only the first record...
dang... i know what it is.. i shouldn't use the FormView, i should've used the repeater for this task :S..
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
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?
You don't ask for much do you :)
You should be able to get to this with something like this:
However, you have to do some additional checks in this case, i.e. the type of the Item that is being DataBound.Code:protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Region tempRegion = (Region)e.Item.DataItem;
}
Have a look here for some more information:
http://msdn.microsoft.com/en-us/libr...databound.aspx
Gary
Thanks Gary, that did the trick :)
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.
Hey,
I am just messing with you :D
Yip, you will pick them up as you go, and never be afraid to ask questions.
Gary
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