|
Please, don't offer code like this, it helps nobody. The guy has taken on a job for which he has no clue what he is doing, so the client is going to get ripped off - his own fault, he should ask for references first, but anyway. Once the guy has used your (dodgy) code to create a login he will ask how to do the next bit of his spec, and before you know it you have written the entire thing.
The simple fact is that people like this a) give a bad impression of developers in general and b) by bidding stupidly low take jobs away from people who can actually do them, but for a realistic price.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi to all,
I am working on a shopping cart project. Here the scenerio is, if the admin adds a new category, that should be shown in the menu. If the admin adds a new sub category , then it should be displayed as the child item of the main category.
Can anybody suggest me how to achieve this.
cheers
sneha
cheers,
sneha
|
|
|
|
|
A dynamic menu will be done using javascript. Just look at any of the menus that exist on the web and work out how to make one work using dynamic properties instead of a static file, or even just write that file as needed.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thank you for replying. I did like this:
using System;
using System.Configuration;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
string name;
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
populate_menu();
}
}
DataSet GetMenuData()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
SqlCommand cmd = new SqlCommand();
ArrayList arl = new ArrayList();
cmd.Connection = con;
cmd.CommandText = "select * from CATEGORY ";
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
cmd.Connection.Open();
sda.Fill(ds, "CATEGORY");
return ds;
}
public void populate_menu()
{
DataSet ds = GetMenuData();
foreach(DataRow drow in ds.Tables["CATEGORY"].Rows)
{
MenuItem masteritem = new MenuItem((string)drow["category_name"]);
name = masteritem.Text;
get_id();
int par_id = Convert.ToInt32 (ViewState["p_id"]);
if (par_id == 0)
{
Menu1.Items.Add(masteritem);
}
else
{
Menu1.Items.Add(masteritem);
}
}
}
public void get_id()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select parent_id from CATEGORY where category_name='"+name+"'";
cmd.Connection.Open();
int pa_id = Convert.ToInt32(cmd.ExecuteScalar());
ViewState["p_id"] = pa_id;
}
}
From this I am getting output like this:
Catering
Plastics
Glassware
cheers,
sneha
|
|
|
|
|
Looks about right. You're not adding subitems, you're adding all your items to the one menu
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
public void populate_menu()
{
DataSet ds = GetMenuData();
foreach(DataRow drow in ds.Tables["CATEGORY"].Rows)
{
MenuItem masteritem = new MenuItem((string)drow["category_name"]);
name = masteritem.Text;
get_id();
par_id = Convert.ToInt32 (ViewState["p_id"]);
if (par_id == 0)
{
Menu1.Items.Add(masteritem);
}
else
{
get_category_name();
ca_name = ViewState["cname"].ToString();
Menu1.Items[0].ChildItems.Add(masteritem);
}
}
}
In this I am unable to find the menu index of a particular category. In this I just tried by giving it as "0".
I want the menuindex based on the category name "ca_name".
cheers,
sneha
|
|
|
|
|
When i run the code below it show error in bold line of code that "Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox'" as i m new to C# programming so i can't resolve it.
protected void gvCouponDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id;
int CouponTypeID;
int Serial_Start;
int serial_End;
TextBox CouponName;
DateTime TranDate;
GridViewRow row = gvCouponDetails.Rows[e.RowIndex];
id = int.Parse(((Label)row.Cells[0].FindControl("lblID")).Text);
TranDate = DateTime.Parse(((TextBox)row.Cells[2].FindControl("tbDate")).Text);
CouponName =((DropDownList)row.Cells[3].FindControl("ddlCoupon")).SelectedValue.ToString();
Serial_Start= int.Parse(((TextBox)row.Cells[4].FindControl("tbSerialStart")).Text);
serial_End = int.Parse(((TextBox)row.Cells[5].FindControl("tbSerialEnd")).Text);
string UpdateQuery = string.Format("update Coupon_Info Set ReceivingDate = '{0}',Coupon_TypeID = {1}, Serial_Start={2},Serial_End={3} where ID= {4}",TranDate.ToString(),CouponTypeID.ToString(),Serial_Start.ToString(),serial_End.ToString(),id.ToString());
DAL da = new DAL();
da.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
int i= da.ExecuteNonQuery(CommandType.Text, UpdateQuery, null);
gvCouponDetails.EditIndex = -1;
boundgridview();
}
ASP code is
<asp:GridView ID="gvCouponDetails"
runat="server"
AutoGenerateColumns="false"
onrowcancelingedit="gvCouponDetails_RowCancelingEdit"
onrowediting="gvCouponDetails_RowEditing"
onrowupdating="gvCouponDetails_RowUpdating"
DataKeyNames="ID"
style="top: 521px; left: 276px; position: absolute; height: 143px; width: 704px">
<Columns>
<asp:CommandField ButtonType="Button"
CancelText="C"
ShowCancelButton="true"
EditText="E"
ShowEditButton="true"
ControlStyle-Width="15px"
ControlStyle-Font-Size="10px"
ControlStyle-ForeColor="Blue"
UpdateText="U" />
<asp:TemplateField HeaderText="Coupon Name">
<ItemTemplate>
<asp:Label ID="tbCouponName" Text='<%# Bind("CouponName") %>' Width="100px" runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCoupon"
DataSourceID="DSCouponType"
Width="100px"
DataTextField="CouponName"
DataValueField="Coupon_TypeID"
runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lblDate" Text='<%# Bind("TransactionDate") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbDate" Text='<%# Bind("TransactionDate") %>' Width="80px" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price">
<ItemTemplate>
<asp:Label ID="lblprice" Text='<%# Bind("Price") %>' runat="server" Width="80px" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbprice" Text='<%# Bind("Price") %>' runat="server" Width="80px" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Serial End">
<ItemTemplate>
<asp:Label ID="lblSerialEnd" Text='<%# Bind("SerialEnd") %>' runat="server" Width="70px" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbSerialEnd" Text='<%# Bind("SerialEnd") %>' runat="server" Width="70px"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Serial Start">
<ItemTemplate>
<asp:Label ID="lblSerialStart" Text='<%# Bind("SerialStart") %>' runat="server" Width="70px" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbSerialStart" Text='<%# Bind("SerialStart") %>' runat="server" Width="70px"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Menu">
<ItemTemplate>
<asp:Label ID="tbMenu" Text='<%# Bind("Cafe_Menu") %>' Width="100px" runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlmenu"
DataSourceID="DSMenu"
Width="100px"
DataTextField="Cafe_Menu"
DataValueField="Cafe_Menu"
runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblDes" Text='<%# Bind("Description") %>' runat="server" Width="70px" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbDes" Text='<%# Bind("Description") %>' runat="server" Width="70px"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Transaction">
<ItemTemplate>
<asp:Label ID="lblSerialStart" Text='<%# Bind("Transaction") %>' runat="server" Width="70px" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbSerialStart" Text='<%# Bind("Transaction") %>' runat="server" Width="70px"/>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
|
|
|
|
|
haleemasher wrote: TextBox CouponName;
Why CoupanName is TextBox Type ?
haleemasher wrote: CouponName =((DropDownList)row.Cells[3].FindControl("ddlCoupon")).SelectedValue.ToString();
Use
String CouponName;
CouponName =((DropDownList)row.Cells[3].FindControl("ddlCoupon")).SelectedValue.ToString();
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I change my code as u suggest but now it show this error in same line of code'System.Web.UI.Control' does not contain a definition for 'SelectedValue' and no extension method 'SelectedValue' accepting a first argument of type 'System.Web.UI.Control' could be found
CouponName =(DropDownList)row.Cells[3].FindControl("ddlCoupon").SelectedValue.ToString();
|
|
|
|
|
CouponName will always contains some string value.Casting it to TextBox is meaningless.If you want to have TextBox based on the value of CouponName use some control logic to get it done.
M.Sendilkumar
|
|
|
|
|
I think you forgot to use text property.
CouponName.text="";
|
|
|
|
|
thnx 4 suggestion but i want to update a gridview and CouponName is my dropdownlist in gridview which i want to update.
|
|
|
|
|
haleemasher wrote: as i m new to C# programming
OK, well, given that the error message is in plain english, I'm not sure what to suggest. If you knew how to program, I'd suggest you break this up into as many lines as you can and step through in the debugger to work out what is going wrong.
As you don't know C#, I assume you're either in a class, or teaching yourself. If you're in a class, you should talk to your teacher. If you're teaching yourself, buy a basic book on C#, BEFORE you try to learn ASP.NET.
And if this is paid work, you are an utter disgrace, and should tell your client right now that you are stealing from them. If you work for a company, I'd expect them to go broke soon, hiring people like you. Your best way forward would be to buy a C# book and work through it, in the hope that when they fail and you look for another programming job, you find yourself actually capable of doing some programming and/or understanding basic error messages.
I assume you didn't write this code. Whoever did, isn't very good. It's horrible.
CouponName =((DropDownList)row.Cells[3].FindControl("ddlCoupon")).SelectedValue.ToString();
There are at least four ways that this code could blow up, it should be on at least 4 lines, with extra code to check the assumptions being made.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
haleemasher wrote: CouponName =((DropDownList)row.Cells[3].FindControl("ddlCoupon")).SelectedValue.ToString();
insead use:
string CouponName = string.empty;
CouponName = ((DropDownList)row.Cells[3].FindControl("ddlCoupon")).Text;
|
|
|
|
|
I have no idea how a textbox is getting involved in his code, but I suspect that Cells[3] has a textbox in it, instead of a drop down. He needs to break this in to steps and use the debugger to work out what is wrong. If he's capable of it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Try this
CouponName.Text =((DropDownList)row.Cells[3].FindControl("ddlCoupon")).SelectedValue.ToString();
|
|
|
|
|
While running this code it show error A page can have only one server-side Form tag.
How i resolve it?
<form id="form1" runat="server">
<fieldset style="width:569px; top: 272px; left: 406px; position: absolute; height: 429px;">
<legend> User Login </legend>
<kswc:UltimateDatePicker ID="UltimateDatePicker1" runat="server">
</kswc:UltimateDatePicker>
<kswc:UltimateCalendar ID="UltimateCalendar1" runat="server">
</kswc:UltimateCalendar>
<kswc:UltimateDatePicker ID="UltimateDatePicker3" runat="server">
</kswc:UltimateDatePicker>
<kswc:UltimateCalendar ID="UltimateCalendar3" runat="server">
</kswc:UltimateCalendar>
</fieldset><
|
|
|
|
|
haleemasher wrote: A page can have only one server-side Form tag.
Its means your web pages contain more than one Server site Form Tag.
Read This For Solution[^]
Thanks !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
This can't be the whole page, as the form is not closed. If you have only one form on this page, there must be a form tag inside one of the controls you are including.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
My guess is that the custom control what you have inside form is generating form.Debug and see the page controls collection and remove if it has more than on server side form.Only one Form runat server is allowed.
M.Sendilkumar
|
|
|
|
|
Hi All!!
I want to create exe file of Asp.Net C# web project so that i can deploy it on any computer. Please guide me how can i do that?and what will be the requirements to deploy it on other computer having no asp.net?
Please guide me!!
|
|
|
|
|
nudma wrote: I want to create exe file of Asp.Net C# web project so that i can deploy it on any computer. Please guide me how can i do that?and what will be the requirements to deploy it on other computer having no asp.net?
An Web Based Application is not like an windows based application which can be installed in any machine. Web Based Application only be hosted on Web Server (IIS) and other user can access it from there.
Your questaions says, you are asking about Web Setup Project.
Here you go :
Visual Studio Setups (Web Setup Part I)[^]
and
Ref[^]
This may helps you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Add web setup project to your exciting project.right click on your websetup project and select add-->project output.
a window should appear.just select ok.
Requirements for runing asp.net web page depends on target mashine but maybe you need:
1-iis
2-.net framework
3-if you use sql database ,you can install sql Express.
|
|
|
|
|
Thankyou so much it worked!!
|
|
|
|
|
you need to read a VERY basic book on ASP.NET, because it's clear you have no idea what it is, or what it does. An ASP.NET application can only run on a web server that has ASP.NET. It gets to users via the web, that's what ASP.NET is for,
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|