|
I usually create a structure of the details item.
Here is an example of code that I use create a header record and then detail items.
<br />
<br />
<br />
<br />
public void UpdateMonoLinePropMaxLimits(int RateGroupCode, DateTime EffectiveDate, MonoLineMaxLimit[] LimitsRows)<br />
{<br />
SqlConnection conn = UAIG.SQL.ConnectionManager.GetConnection();<br />
SqlCommand cmd1 = new SqlCommand();<br />
cmd1.CommandText = "dbo.uspUpdatePropMaxLimit";<br />
cmd1.Connection = conn;<br />
cmd1.CommandType = CommandType.StoredProcedure;<br />
cmd1.Parameters.Add(new SqlParameter("@RateGroupCode", RateGroupCode));<br />
cmd1.Parameters.Add(new SqlParameter("@EffectiveDate", EffectiveDate));<br />
cmd1.Parameters.Add(new SqlParameter("@NetID", UAIG.Settings.ApplicationSettings.GetUser()));<br />
SqlParameter prmReturnValue = new SqlParameter("@ReturnValue", SqlDbType.Int);<br />
prmReturnValue.Direction = ParameterDirection.ReturnValue;<br />
cmd1.Parameters.Add(prmReturnValue);<br />
conn.Open();<br />
SqlTransaction trans = conn.BeginTransaction();<br />
cmd1.Transaction = trans;<br />
cmd1.ExecuteNonQuery();<br />
<br />
<br />
int MaxLimitGroup = int.Parse(prmReturnValue.Value.ToString());<br />
SqlCommand cmd2 = new SqlCommand();<br />
cmd2.CommandType = CommandType.StoredProcedure;<br />
cmd2.Connection = conn;<br />
cmd2.CommandText = "dbo.uspInsertMaxLimit";<br />
cmd2.Parameters.Add(new SqlParameter("@MaxLimitGroup", MaxLimitGroup));<br />
SqlParameter prmConstructionTypeCode = new SqlParameter("@ConstructionTypeCode", SqlDbType.Int);<br />
cmd2.Parameters.Add(prmConstructionTypeCode);<br />
SqlParameter prmSprinklered1_6 = new SqlParameter("@Sprinklered1_6", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmSprinklered1_6);<br />
SqlParameter prmSprinklered7_8 = new SqlParameter("@Sprinklered7_8", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmSprinklered7_8);<br />
SqlParameter prmNonSprinklered1_6 = new SqlParameter("@NonSprinklered1_6", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmNonSprinklered1_6);<br />
SqlParameter prmNonSprinklered7_8 = new SqlParameter("@NonSprinklered7_8", SqlDbType.Money);<br />
cmd2.Parameters.Add(prmNonSprinklered7_8);<br />
<br />
foreach (MonoLineMaxLimit item in LimitsRows)<br />
{<br />
prmConstructionTypeCode.Value = item.ConstructionTypeCode;<br />
prmSprinklered1_6.Value = item.Sprinklered1_6;<br />
prmSprinklered7_8.Value = item.Sprinklered7_8;<br />
prmNonSprinklered1_6.Value = item.NonSprinklered1_6;<br />
prmNonSprinklered7_8.Value = item.NonSprinklered7_8;<br />
<br />
cmd2.Transaction = trans;<br />
cmd2.ExecuteNonQuery();<br />
<br />
}<br />
<br />
trans.Commit();<br />
conn.Dispose();<br />
}<br />
<br />
public struct MonoLineMaxLimit<br />
{<br />
public int ConstructionTypeCode;<br />
public decimal Sprinklered1_6;<br />
public decimal Sprinklered7_8;<br />
public decimal NonSprinklered1_6;<br />
public decimal NonSprinklered7_8;<br />
}<br />
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
So you can have two different insert commands for the same form?
|
|
|
|
|
hi everybody i want know how to add webparts nd webpartszone at runtime,
see the site www.netvibes.com
i wnt to add web parts same like thatt
reply me quic thank you
intresting in asp.net
|
|
|
|
|
For a while now, I've simply used panels, and made them visible=true/false to change the view.
However I started playing with the multi view and it seems to have them same functionality and well only one seems to be able to be active at a time.
When I was reading about a multi view and read that it loads all controls reguardless of active view. (maybe I misunderstood this part)
In my current setup I have:
If i have a multi view with three views, or a page with 3 panels.
The views would have a gridview, listview, and a details view, and same with the panels.
Now due to the nature of these views, I have been using 3 different object sources, one for each.
So now comes my question:
If I do a multi view, does that mean that every time the page is reloaded, that it will requery the DBF for each of the views? since they are all in existance? (thus, 3 database queries per page load?)
What about if a panel that contains a gridview that is not visible. I think that the object is not even sent to the client, and I'd assume that it would not even be created, and thus no object query made. Is that a safe assumption?
Lastly, does anyone know a good way to track/count database queries made every time a page is loaded? Maybe a code snip or a log file that could be checked?
Drathmar
|
|
|
|
|
Drathmar wrote: If I do a multi view, does that mean that every time the page is reloaded, that it will requery the DBF for each of the views? since they are all in existance? (thus, 3 database queries per page load?)
Only the active view makes a request to DB, and it's not for all time, basically the control in the active view is filled with data from DB for the first time it displays, and for the next postbacks it is normally recreated from the ViewState instead of DB..
Drathmar wrote: What about if a panel that contains a gridview that is not visible. I think that the object is not even sent to the client, and I'd assume that it would not even be created, and thus no object query made. Is that a safe assumption?
The object does get created regardless of its visibility, but normally the control with the Visible=false does not bind data, it means it does not make a request to DB. However, if the Visible is set too late in the control life cycle, it still executes the Db query, but does not render.
Drathmar wrote: Lastly, does anyone know a good way to track/count database queries made every time a page is loaded? Maybe a code snip or a log file that could be checked?
The simple way is to use the SQL Profiler to profile the current DB to see any queries sent to the database when the page is loaded. In addition, you can use your code or any library out there like log4net to log any calls that are made to your data access code.
|
|
|
|
|
I'm a long-time developer new to C# and ASP.NET. One of the first sites I'm working on will be a collection of documents, which would grow from visitor contributions. I would like this to work much like it does at The Code Project.
I'm trying to figure out the best way to do this. I could simply store the documents as Web pages. Or I could store the documents as Web pages and simply index them in a database. Or I could actually store the documents in the database and dish them out as requested, I assume with some sort of cache to improve performance.
I know The Code Project uses a combination of a database and Web pages but I don't know exactly how. Can anyone offer some pros and cons of these different approaches. Please include as much detail as you'd care to as I'm pretty new to Web development.
Thanks
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
|
|
|
|
|
Hello,
In ASP.NET 2.0 application while using Forms Authentication, if user sees Login page due to session timout, is there anyway I can find out at login page that user came to this page because of session timeout and can show some message to user that he/she is redirected to this page because of Session timeout.
Appreciate any help in this regard.
- ashish
|
|
|
|
|
Hi there. One of the ways you can do is to use the Session Start event, and in the handler you can check if the authentication cookie is existing or not. If not, this is a new user, otherwise the existing user is kicked out due to the session time out.
|
|
|
|
|
I am binding dropdown with database using datasource.
I don't have any --Select-- option in the database.
Now i wan't to bind the --select-- option as the first element of dropdown so that the Index of --select- option is 0
This all the Bind was doing dynamically
Kindly help me
Madhu
|
|
|
|
|
After you have bound the datasource to the dropdown insert an item to it
ddl.Items.Insert(0, "--Select--");
only two letters away from being an asset
|
|
|
|
|
Hi,
you can use following query instead
SELECT 0, '--Select--'
FROM Products
union
select productid,productname from products
just replace ur table names.
hope this works.
Nitin...
|
|
|
|
|
Hi all,
I am using Repeater Control in asp.net 2.0. In this, i ve dynamically created the Repeater Templates ( Header, Item, Footer, etc..) , following the MSDN URL and it works fine.
http://msdn2.microsoft.com/en-us/library/0e39s2ck.aspx[^]
My Objective:
I wish to Construct each Template in different Class, NOT in the same class (Codebehind class) where i ve used my Repeater control in the Page (.aspx file).
In this , how can i implement the Item_DataBinding event handler ?
I need the logic in which it can be implemented ? Pls. Help me ?
-- modified at 9:46 Friday 25th August, 2006
Regards,
Jay
|
|
|
|
|
Hi, if I understand correctly.
You want to use a function from a different class, to implement Item_databinding.
You can maybe have a look at the Objectdatasource. The ODS can be used as a way to call a method from another class... here is a simple example (I used a gridview in this example).
<asp:ObjectDataSource id="odsInvoice" TypeName="Mynamespace.Business.Invoices"<br />
SelectMethod="GetDetails" runat="server"><br />
</asp:ObjectDataSource><br />
<br />
<asp:gridview id="gvInvoices" runat="server" datasourceid="odsInvoice" <br />
autogeneratecolumns="true" Width="980" AllowSorting="False" />
Here I use a ODS to fill my gridview from another class that contains the method.
|
|
|
|
|
Thanks for your reply. But this is not, what i am expecting. I think, my question is not clear.
I wish to create the Repeater Control's Templates Dynamically using C# Class.
For that, u am using a class,
public class MyTemplates : System.Web.UI.ITemplate
{
public MyTemplates(template_type){ }
//Other code here.
}
This Class is Present in the Code Behind (.cs) of the Web (.aspx) Page.
Also this Template Class (mentioned above) is Present Inside of a Class which Inherits Page Class. I ve given the outline below.
public partial class ExampleClass: System.Web.UI.Page
{
Page_Load(object sender, EventArgs e) { }
static void Item_DataBinding(object sender, System.EventArgs e) { }
public class MyTemplates : System.Web.UI.ITemplate { }
}
This "Item_DataBinding" event handler is used by MyTemplates Class, Ok. But, this event handler is belongs to Page Class.
In this, if i take out the "MyTemplates" class and Put it as a seperate class, how can i make use of the "Item_DataBinding" event handler?. This is my doubt?
My AIM is to Create Dynamic Templates outside ( C# Class), and use that Template in my Web Page Code Behind class , and bind the values of the Controls in the Page using "Item_DataBinding" event handlder.
Any Suggestions ?
Regards,
Jay
|
|
|
|
|
In the C file I have this function
DllExport int FunctionName(char *oStrP, const char *iStrP){<br />
}<br />
I did this to import it:
[DllImport(@"path\Mydll.dll", EntryPoint="FunctionName", SetLastError=true, CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)]<br />
unsafe public static extern int FunctionName(ref char * oStrP, ref char [] iStrP);
but I'm getting errors when actually calling the function.
I've tried string, char[], char*, but it always fails.
What should be the correct syntax for this?
tnx !!
I've found a living worth working for, but I haven't found work worth living for.
<marquee>
|
|
|
|
|
|
|
Can anybody please tell me how to send an xml file to a remote webmethod as an input? we dont have any access to the webmethod code and dont know the implimentation part. We just need to send our input file in xml format or the xml text itself to the webmethod and the webmethod is going to return an output xml string to us. I need to do this using aspx page and c#.net language. I tried sending the xml text with httpRequest and Response, but I got forbidden error from the server. my problem is just how to send a text in the form of parameter to any webmethod?
thanks in advance,
regards,
anil
|
|
|
|
|
|
thanks for the link...will go through it.
|
|
|
|
|
Because the server response says something about forbidden , so IMO you first need to make sure that the web service is accessible to your client side code, then have a look at the contract of the service to make a call properly.
|
|
|
|
|
thanks for the suggesion. i finally found out that there was one tag which was not being accepted by the webservice. there was no syntactical problem with the tag. but after removing that tag, the request went successfully! this is strange. but i am trying to find the real casue.
any way.. thanks for your help.
-- modified at 2:45 Monday 28th August, 2006
|
|
|
|
|
I created the asp.net project.
It contains with java script, htm and aspx.
java script for the menu, when user click the link load the relevent pages.
htm page load without problem, but aspx pages not load, giving the following runtime error.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customerrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customerrors> tag should then have its "mode" attribute set to "Off".
<configuration>
<system.web>
<customerrors mode="Off">
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customerrors> configuration tag to point to a custom error page URL.
<configuration>
<system.web>
<customerrors mode="RemoteOnly" defaultredirect="mycustompage.htm">
please help me to fix that error and tell me whats the reason?
i already set the customErrors mode to the off
i need your help immeadatly
thanx
Software Devolper in future.
|
|
|
|
|
Your code snipets are not displayed. Check the checkbox "Ignore HTML tags in this message (good for code snippets)" to your post. We cannot see the code.
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
I created the asp.net project.
It contains with java script, htm and aspx.
java script for the menu, when user click the link load the relevent pages.
htm page load without problem, but aspx pages not load, giving the following runtime error.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
please help me to fix that error and tell me whats the reason?
i already set the customErrors mode to the off
i need your help immeadatly
thanx
Software Devolper in future.
Software Devolper in future.
|
|
|
|
|