|
If the query is returning null it could cause this error.
Check your query.
Also add a try Catch so the program doesn't stop running.
Hope this helps.
|
|
|
|
|
Hi all,
I m trying to create an custom shopping cart.
the scene is whenever an user adds any product into his shopping cart the quantity of the product which he has added should be reduced from the actual quantity of the product so as we may not get order more that the actual quantity. during the time the product remains in the users cart the the product quantity available for other user is shown less so as they may not order this product.
now the cart is set to expire in 15min if idle.
I m using cookies to create the cart. storing the product Id and quantity but the problem is how can I update the quantity if a person's cart expires.
any suggestion.
thanks & regards
Vijay V.
Yash Softech
|
|
|
|
|
You need to be able to check if the cookie has expired. When the cookie has expired move the quantity back into the table where the quantity of the product is.
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
hi,
i can read that but how can I trace that cookie is expired and how do I maintain that this much quantity is taken by someone or is in someones cart so not allow anyone else add to their cart?
how can I detect that this product is added in someones cart??
Vijay V.
Yash Softech
|
|
|
|
|
I think like Christian said below it may be better to use tables.
Imagine one of your tables in your database is the shopping cart and then store the details in there. You could put an expiry time on the product, so say 1 hour and after that it is then removed from the shopping cart.
Run some code in your application which checks the table for any items which have been in there longer than an hour, if so delete them and they will then be removed from the shopping cart.
If you think logically about how to do this with tables it will become quite easy.
feel free to ask more questions
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
thanks for valuable suggestions.
I think I must create an web schedular that will constantly check for product expiry time and if they are still there after that I mean checkout is not done I must remove that items from that.
thanks for the help guys.
Vijay V.
Yash Softech
|
|
|
|
|
You have a design issue. Don't use cookies to store these details. Persist the details in a database, put a column which has expiry time. Write a SQL job which polls these table and remove expired rows.
|
|
|
|
|
does this mean I must put the details of the product being added to a temp table and adding the expiry time in an row and creating a scheduler which will keep on checking this time and if its about to expire time then update the products table with these values again and remove the temp table data.
but in this I will be updating the expiry time of the cart each time the user adds a new item in its cart with in this expiry time. the new time will be again the max time of expiry. so i will have to maintain multiple values for a particular user as shopping cart can have multiple products.
Vijay V.
Yash Softech
|
|
|
|
|
Just store the product ID in the table with the date it was added and the session ID. That will keep it simple.
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
session id or user id?
how to delete this data when expired?
Vijay V.
Yash Softech
|
|
|
|
|
As I said before set a timer which checks what date it was added and then after an hour delete the row from the table.
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
thanks for the help.
Vijay V.
Yash Softech
|
|
|
|
|
Hi
I saw many pages about this subject in microsoft msdn website but I don't how to do it.What I mean is I have downloaded virtual pc 2007 already but what next should I do?
I am too late but i will never give up
|
|
|
|
|
Hi all,
I have master page. In that i placed a LinkButton(Log Out).
If user clicks on this logout button, i am entering the login & logout information into database and i am deleting temporary folders.
Probem1 : When user closes Browser window by Closebutton(X), i need to enter the logout information into database & i need to delete temporary folders and files.
Problem2 : After user logout, how can i restrict user to navigate through previous pages by using Brower Back(< & Forward(->) buttons.
Please suggest how to achieve this...
Thanks in advance.
|
|
|
|
|
sekhar.k wrote: Probem1 : When user closes Browser window by Closebutton(X), i need to enter the logout information into database & i need to delete temporary folders and files.
function UpdateDataBase()<br />
{<br />
if(window.event.clientX < 0 && window.event.clientY <0)<br />
{<br />
window.open("UrLogic.aspx", "OpenWindow_Close_Session",'left=12000,top=1200,width=10,height=1');<br />
}<br />
}
Urlogic.aspx will contain the database related operation and Check the locatoion of popup. user should not able to see it.
Call it on Masterpage onUnload
sekhar.k wrote: Problem2 : After user logout, how can i restrict user to navigate through previous pages by using Brower Back(< & Forward(-> buttons.
javascript:window.history.forward(1);
|
|
|
|
|
Thanks for your suggestion. I will try as u told.
But i have a small doubt.
For Problem1, Do i need to place the above javascript code in MasterPage.
For Problem2, Where i nned to place'javascript:window.history.forward(1).
This i have apply only after user logout if he tries to navigate through Browser -> & <- Buttons.
Thanks in advance.
Cheers,
sekhar
|
|
|
|
|
I tried ur logic. Its not working properly.
If any where i went wrong, let me know.
Here is my code
MastrPage:
==========
Default.master(Design)
<%@ Master Language="C#" CodeFile="Default.master.cs" Inherits="Default_master" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type= "text/javascript">
function UpdateDataBase()
{
// Check Browser Close [X] , Alt+F4 , File -> Close
if (window.event.clientX < 0 && window.event.clientY < 0)
{
window.open("DummyPage.aspx?test=test", "OpenWindow_Close_Session", 'left=12000,top=1200,width=10,height=1');
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div class="header">
<h1 style="color: #FFFFFF">Prospecta technologies</h1>
<h2 style="color: #FFFFFF">Proxy Ads Management System</h2>
<div class="nav">
<asp:Label ID="lbl_Welcome" runat="server" Visible="False" Font-Bold="True"
ForeColor="White"></asp:Label>
|
<asp:SiteMapPath id="SiteMapPath1" runat="Server" PathSeparator=" > " RenderCurrentNodeAsLink="true" />
|
<asp:LinkButton ID="hlink_Logout" runat="server"
onclick="hlink_Logout_Click" CausesValidation="False"
ValidationGroup="Click here for Logout" Visible="False">Logout</asp:LinkButton>
</div>
<asp:Menu id="menua" runat="server"
cssclass="menua"
orientation="Horizontal"
maximumdynamicdisplaylevels="0"
skiplinktext=""
staticdisplaylevels="2" >
<Items>
<asp:MenuItem NavigateUrl="~/LoginPage.aspx" Text="Login" Value="Login"
ToolTip="Login">
</asp:MenuItem>
<asp:MenuItem Text="About Us" ToolTip="About Us" Value=" About Us"
NavigateUrl="~/AboutUs.aspx">
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ContactUs.aspx" Text="Contact Us"
Value="Contact Us" ToolTip="Contact Us"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
<asp:contentplaceholder id="Main" runat="server" onunload="Main_Unload" />
<div class="footerbg">
<div class="footer">
<asp:Menu id="menub" runat="server"
cssclass="menub"
orientation="Horizontal"
maximumdynamicdisplaylevels="0"
skiplinktext=""
staticdisplaylevels="2" Height="16px" Width="290px" >
<Items>
<asp:MenuItem NavigateUrl="~/LoginPage.aspx" Text="Login" ToolTip="Home"
Value="Home"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/AboutUs.aspx" Text="About Us" ToolTip="About Us"
Value="About Us"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ContactUs.aspx" Text="Contact Us"
ToolTip="Contact Us" Value="Contact Us"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
</form>
</body>
</html>
My CodeBlock
Default.master.cs:(The below method is not executing when i closes the browser. I tried by placing break point)
==================
protected void Main_Unload(object sender, EventArgs e)
{
string str = "<script language=javascript>";
str += "javascript:UpdateDataBase();";
str += "</script>";
Page.RegisterStartupScript("test", str);
//string script;
//script = @"<SCRIPT language='javascript'> + "function name</SCRIPT>";
//this.RegisterStartupScript("MyAlert", script);
}
//////////////////////////////
DummyPage.aspx.cs(This is the page i am redirecting to user from javasript method)
PageLoad()
{
if(!Page.IsPostBack)
{
if(Request.QueryString["msg"]!="") // I am trying to create a direcory for Checking purpose
{
DirecoryInfo dir = new DirecoryInfo(@"D:\Test");
if(dir.Exists == false)
dir.Create();
}
}
}
..................
Please suggest me where i went wrong.
Thnks in advance.
|
|
|
|
|
sekhar.k wrote: Problem2 :
It is quite difficult to control the back button in the browser.
Even with the javascript line of code posted below there is still no quarantee that a user wont disable the javascript. The best bet is to build your application so it doesnt matter if a user goes back through pages
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
Hi
I have gridview and I am using gridview1_rowupdating event to update the gridview, but when I am using the code given below its not working. I do not know why it is not updating, it is not even showing error. please help me resolve this problem.
Thanks
protected void gv_RowUpdating1(object sender, GridViewUpdateEventArgs e)
{
connectAccessDb();
int i = e.RowIndex;
string id = (gv.Rows[e.RowIndex].FindControl("lblCID") as Label).Text;
string comp = (gv.Rows[e.RowIndex].FindControl("txtCName") as TextBox).Text;
string address = (gv.Rows[e.RowIndex].FindControl("txtCAddr") as TextBox).Text;
string city = (gv.Rows[e.RowIndex].FindControl("txtCcity") as TextBox).Text;
string strQuery = "UPDATE companydetail SET companyname=@comp, companyaddress=@address, companycity=@city where id=@id";
cmd = new OleDbCommand(strQuery, cn);
cmd.Parameters.Add("@id", OleDbType.Integer).Value = Convert.ToInt32(id);
cmd.Parameters.Add("@comp", OleDbType.VarChar).Value = comp;
cmd.Parameters.Add("@address", OleDbType.VarChar).Value = address;
cmd.Parameters.Add("@city", OleDbType.VarChar).Value = city;
cmd.ExecuteNonQuery();
cmd.ExecuteNonQuery();
cn.Close();
bindData();
}
private void bindData()
{
connectAccessDb();
da = new OleDbDataAdapter("SELECT id,companyname,companyaddress,companycity from companydetail order by companyname", cn);
da.Fill(ds, "companydetail");
gv.DataSource = ds;
gv.DataBind();
cn.Close();
}
private void connectAccessDb()
{
cn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + strRootDir + "App_Data\\newsdb.mdb");
cn.Open();
}
|
|
|
|
|
How Can I use ListBox for multiple values in gridview in asp.net 2.0
while editing only.
look on below code:
<asp:GridView ID="grdBusScheduling" runat="server" ForeColor="#333333" DataKeyNames="DetailID"
AutoGenerateColumns="False" CellPadding="5" Visible="False" DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<b>There is no Bus Schedule</b>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<%#Eval("ForDate", "{0:dd-MMM-yyyy}")%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FareForAdult" HeaderText="Fare For Adult" />
<asp:BoundField DataField="FareForChild" HeaderText="Fare For Child" />
<asp:BoundField DataField="FareForSr" HeaderText="Fare For Senior" />
<%--<asp:BoundField DataField="OpenStatus" HeaderText="Open" />--%>
<asp:TemplateField HeaderText="Open">
<ItemTemplate>
<%#Eval("OpenStatus")%>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" HeaderText="Edit" />
</Columns>
<FooterStyle BackColor="#003366" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#003366" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#003366" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringTravel %>"
SelectCommand="BusDetailSelectByFields" SelectCommandType="StoredProcedure"
UpdateCommand="BusDetailEditByDetailID" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCityFrom" Name="CityFromID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlCityTo" Name="CityToID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlBusType" Name="BusTypeID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlVendor" Name="VendorID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlBus" Name="BusID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="Date1" Name="FromDate" PropertyName="Text" Type="DateTime" />
<asp:ControlParameter ControlID="Date2" Name="ToDate" PropertyName="Text" Type="DateTime" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="DetailID" Type="Int64" />
<asp:Parameter Name="FareForAdult" Type="Int64" />
</UpdateParameters>
<UpdateParameters>
<asp:Parameter Name="DetailID" Type="Int64" />
<asp:Parameter Name="FareForChild" Type="Int64" />
</UpdateParameters>
<UpdateParameters>
<asp:Parameter Name="DetailID" Type="Int64" />
<asp:Parameter Name="FareForSr" Type="Int64" />
</UpdateParameters>
</asp:SqlDataSource>
You get the best out of others when you give the best of yourself.
|
|
|
|
|
i have used the following code to verify email domain given in code project articles but it was not working,can u please sort my problem out.....
public static bool Send(string aa)
{
string[] host = (aa.Split('@'));
string hostname = host[1];
IPHostEntry IPhst = Dns.Resolve(hostname);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
Socket s = new Socket(endPt.AddressFamily,
SocketType.Stream, ProtocolType.Tcp);
s.Connect(endPt);
}
thanks in advance....
Maniiiiiiiiiiiiiii
|
|
|
|
|
Could you specify what you mean by "not working"? Does it compile? Does it run? What happens? Do you get any kind of error message?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
exception is thrown which shows that domain does not exists even in case of yahoo.com,gmail.com
Maniiiiiiiiiiiiiii
|
|
|
|
|
currently i m using asp.net with c# (2.0 framework).
here i created a datatable and put these values in gridview and i have displayed. But when i check the gridview row and column count, the row count is coming correctly. but the column count always remains 0. y? kindly help me... below i have attached the coding.........
DataTable DTable;
DataRow DRow;
DataColumn DCol;
sqlda=new System.Data.SqlClient.SqlDataAdapter("select tmp_values from tbl_table1", conn);
sqlda.Fill(ds);
DTable = new DataTable("Headers");
DCol = new DataColumn("Head");
DTable.Columns.Add(DCol);
DRow = DTable.NewRow();
for (int i = 0; i <ds.Tables[0].Rows.Count; i++)
{
DCol = new DataColumn("" + ds.Tables[0].Rows[i][0].ToString() + "");
DTable.Columns.Add(DCol);
DCol = new DataColumn("" + ds.Tables[0].Rows[i][0].ToString() + " " + " Remarks");
DTable.Columns.Add(DCol);
}
DTable.Rows.Add(DRow);
GridView1.DataSource = DTable;
GridView1.DataBind();
DTable.Columns.Count = 5 (its correct, but when bind with gridview and check the column count its zero)
GridView1.Rows.Count = 1 (its correct)
GridView1.Columns.Count = 0 (its incorrect, the answer should be 5)
Help me!!! - KARAN
|
|
|
|
|
Hi all,
iam facing problem how i display associated record details from database inside formview control
i have table control contains 32 cells in row and added linkbutton dynamicallly to table cells and added event handler as well but when iam clicking on all linkbuttons only one record is displying inside formview .
but i have to display associated record inside formview on linkbuton click.
Any hint ?
Best Regards
Rameez
|
|
|
|