|
Hello,
I set the code like this in html......
-----------------------------------------------------------------------------
<asp:datalist id="dlGallery" runat="server" OnCancelCommand="dlGallery_CancelCommand" OnUpdateCommand="dlGallery_UpdateCommand"
OnEditCommand="dlGallery_EditCommand" EditItemStyle-BackColor="lightgreen" AlternatingItemStyle-BackColor="Gainsboro"
HeaderStyle-BackColor="#aaaadd" Width="150px" Font-Size="8pt" Font-Name="Verdana" CellSpacing="0"
CellPadding="3" GridLines="Both" BorderWidth="1" BorderColor="black" DataKeyField="AD_TITLE">
<ItemTemplate>
<asp:LinkButton ID="lbGalleryEdit" Text="Edit" CssClass="changeLinks" CommandName="Edit" runat="server" />
<%# DataBinder.Eval(Container.DataItem, "AD_TITLE") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Textbox1" Text='<%# DataBinder.Eval(Container.DataItem, "AD_TITLE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox2" Text='<%# DataBinder.Eval(Container.DataItem, "AD_TYPE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox3" Text='<%# DataBinder.Eval(Container.DataItem, "category_id") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox4" Text='<%# DataBinder.Eval(Container.DataItem, "AD_DESCRIPTION") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox5" Text='<%# DataBinder.Eval(Container.DataItem, "area") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox6" Text='<%# DataBinder.Eval(Container.DataItem, "unit") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox7" Text='<%# DataBinder.Eval(Container.DataItem, "PRICE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox8" Text='<%# DataBinder.Eval(Container.DataItem, "WebUrl") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox9" Text='<%# DataBinder.Eval(Container.DataItem, "LOCATION") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox10" Text='<%# DataBinder.Eval(Container.DataItem, "plotname") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox11" Text='<%# DataBinder.Eval(Container.DataItem, "EMAIL_ID") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox12" Text='<%# DataBinder.Eval(Container.DataItem, "PHONENO") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:LinkButton ID="lbGalleryUpdate" Text="Update" CommandName="Update" CssClass="changeLinks" runat="server" />
<asp:LinkButton ID="lbGalleryCancel" Text="Cancel" CommandName="Cancel" CssClass="changeLinksLast"
runat="server" />
</EditItemTemplate>
</asp:datalist>
-----------------------------------------------------------------------------
and the C# code like this
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Newclassified
{
/// <summary>
/// Summary description for samble11.
/// </summary>
public class Youradvts : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList dlGallery;
protected System.Web.UI.WebControls.DataList DataList1;
DataTable dt;
SqlDataReader sdr;
public DataTable Cart;
protected System.Web.UI.WebControls.Label lblmem_id;
public DataView CartView;
connection constr=new connection();
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["DL3_ShoppingCart"] == null)
{
Cart = new DataTable();
Cart.Columns.Add(new DataColumn("Title", typeof(string)));
Cart.Columns.Add(new DataColumn("Type", typeof(string)));
Cart.Columns.Add(new DataColumn("Category", typeof(string)));
Cart.Columns.Add(new DataColumn("Description", typeof(string)));
Cart.Columns.Add(new DataColumn("Area", typeof(string)));
Cart.Columns.Add(new DataColumn("Unit", typeof(string)));
Cart.Columns.Add(new DataColumn("Price", typeof(string)));
Cart.Columns.Add(new DataColumn("Web URL", typeof(string)));
Cart.Columns.Add(new DataColumn("Location", typeof(string)));
Cart.Columns.Add(new DataColumn("Name", typeof(string)));
Cart.Columns.Add(new DataColumn("Email ID", typeof(string)));
Cart.Columns.Add(new DataColumn("Phone No", typeof(string)));
Session["DL3_ShoppingCart"] = Cart;
// first load -- prepopulate with some data
for (int i=1; i<5; i++)
{
// dr[0] = ((int)((i%2)+1)).ToString();
// dr[1] = "Item " + i.ToString();
// dr[2] = ((double)(1.23 * (i+1))).ToString();
DataRow dr = Cart.NewRow();
dr[0] = "Title" + i.ToString();
dr[1] = "Type " + i.ToString();
dr[2] = "Category" + i.ToString();
dr[3] = "Description" + i.ToString();
dr[4] = "Area " + i.ToString();
dr[5] = "Unit" + i.ToString();
dr[6] = "Price" + i.ToString();
dr[7] = "WebURL" + i.ToString();
dr[8] = "Location"+i.ToString();
dr[9] = "Name"+i.ToString();
dr[10] = "Email ID " + i.ToString();
dr[11] = "Phone No"+i.ToString();
Cart.Rows.Add(dr);
}
}
else
Cart = (DataTable)Session["DL3_ShoppingCart"];
CartView = new DataView(Cart);
//CartView.Sort = "Item";
if (!IsPostBack)
BindList();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dlGallery.SelectedIndexChanged += new System.EventHandler(this.dlGallery_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
void BindList()
{
try
{
connection constr=new connection();
string ss=Session["uid"].ToString();
string mem_id;
string sstr1="select id from tbl_userreg where username='"+ss+"'";
sdr=constr.reader(sstr1);
while(sdr.Read())
{
mem_id=sdr["id"].ToString();
lblmem_id.Text=mem_id.ToString();
}
string str="select AD_TITLE,AD_TYPE,AD_DESCRIPTION,category_id,LOCATION,EMAIL_ID,PHONENO,DATE_POSTED from ads where member_id="+Convert.ToInt32(lblmem_id.Text.ToString())+"";
dt=new DataTable();
dt=constr.ExQselect(str);
if(dt.Rows[0].ItemArray[0].ToString()=="")
{
lblmem_id.Visible=true;
lblmem_id.Text="Please Add Your Advertisement";
}
dlGallery.DataSource=dt;
dlGallery.DataBind();
}
catch
{
lblmem_id.Visible=true;
lblmem_id.Text="Kindly Register YourSelf To ADVERTISE FREELY For 60 Days";
}
}
private void dlGallery_EditCommand(object sender, System.EventArgs e)
{
//dlGallery.EditItemIndex = e.AD_TITLE.ItemIndex;
BindList();
}
private void dlGallery_UpdateCommand(object sender, System.EventArgs e)
{
// string item = ((System.Web.UI.WebControls.Label)e.AD_TITLE.FindControl("Label1")).Text;
// string qty = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text1")).Text;
string title = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text1")).Text;
string type= ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text2")).Text;
string category = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text3")).Text;
string description = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text4")).Text;
string area = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text5")).Text;
string unit= ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text6")).Text;
string price = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text7")).Text;
string weburl = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text8")).Text;
string location = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text9")).Text;
string name= ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text10")).Text;
string emailid = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text11")).Text;
string phoneno= ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text12")).Text;
// with a database, we'd use an update command. Since we're using an in-memory
// DataTable, we'll delete the old row and replace it with a new one
//remove old entry
//CartView.RowFilter = "Item='"+item+"'";
if (CartView.Count > 0) //item exists in cart
CartView.Delete(0);
CartView.RowFilter = "";
//add new entry
DataRow dr = Cart.NewRow();
dr[0] = title;
dr[1] = type;
dr[2] = category;
dr[3] = description;
dr[4] = area;
dr[5] = unit;
dr[6] = price;
dr[7] = weburl;
dr[8] = location;
dr[9] = name;
dr[10] = emailid;
dr[11] = phoneno;
Cart.Rows.Add(dr);
dlGallery.EditItemIndex = -1;
BindList();
}
private void dlGallery_CancelCommand(object sender, System.EventArgs e)
{
dlGallery.EditItemIndex = -1;
BindList();
}
-------------------------------------------------------------------------
But while running getting the error like this
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(159): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(161): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(169): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(168): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(160): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(158): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(167): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(166): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(165): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(162): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(164): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(163): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\index.aspx(2616): Could not find any attribute 'align' of element 'marquee'.
---------------------------------------------------------------------------
please help me to solve this problem.....
thanks
Bijesh
|
|
|
|
|
bijeshputhalath wrote: string title = ((System.Web.UI.WebControls.TextBox)e.AD_TITLE.FindControl("Text1")).Text;
You should remove "AD_TITLE ".
string title = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text1")).Text;
bijeshputhalath wrote: C:\Inetpub\wwwroot\approvedplotfinal\index.aspx(2616): Could not find any attribute 'align' of element 'marquee'.
Where do you set "marquee" in your code??
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hello
while i removing AD_TITLE and try with your suggestion....But the following error comes
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(151): 'System.EventArgs' does not contain a definition for 'AD_TITLE'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(163): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(171): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(170): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(162): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(161): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(169): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(168): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(167): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(164): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(166): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(165): 'System.EventArgs' does not contain a definition for 'FindControl'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(160): 'System.EventArgs' does not contain a definition for 'FindControl'
-----------------------------------------------------------------------------
Now My code is below
---------------------------------
private void dlGallery_EditCommand(object sender, System.EventArgs e)
{
dlGallery.EditItemIndex = e.AD_TITLE.ItemIndex;
BindList();
}
private void dlGallery_updateCommand(object sender, System.EventArgs e)
{
// string item = ((System.Web.UI.WebControls.Label)e.FindControl("Label1")).Text;
// string qty = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text1")).Text;
string title = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text1")).Text;
string type= ((System.Web.UI.WebControls.TextBox)e.FindControl("Text2")).Text;
string category = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text3")).Text;
string description = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text4")).Text;
string area = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text5")).Text;
string unit= ((System.Web.UI.WebControls.TextBox)e.FindControl("Text6")).Text;
string price = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text7")).Text;
string weburl = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text8")).Text;
string location = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text9")).Text;
string name= ((System.Web.UI.WebControls.TextBox)e.FindControl("Text10")).Text;
string emailid = ((System.Web.UI.WebControls.TextBox)e.FindControl("Text11")).Text;
string phoneno= ((System.Web.UI.WebControls.TextBox)e.FindControl("Text12")).Text;
// with a database, we'd use an update command. Since we're using an in-memory
// DataTable, we'll delete the old row and replace it with a new one
//remove old entry
//CartView.RowFilter = "Item='"+item+"'";
if (CartView.Count > 0) //item exists in cart
CartView.Delete(0);
CartView.RowFilter = "";
//add new entry
DataRow dr = Cart.NewRow();
dr[0] = title;
dr[1] = type;
dr[2] = category;
dr[3] = description;
dr[4] = area;
dr[5] = unit;
dr[6] = price;
dr[7] = weburl;
dr[8] = location;
dr[9] = name;
dr[10] = emailid;
dr[11] = phoneno;
Cart.Rows.Add(dr);
dlGallery.EditItemIndex = -1;
BindList();
}
----------------------------------------------------------------------------
<asp:datalist id="dlGallery" runat="server" OnCancelCommand="dlGallery_cancelCommand" OnUpdateCommand="dlGallery_updateCommand"
OnEditCommand="dlGallery_EditCommand" EditItemStyle-BackColor="lightgreen" AlternatingItemStyle-BackColor="Gainsboro"
HeaderStyle-BackColor="#aaaadd" Width="150px" Font-Size="8pt" Font-Name="Verdana" CellSpacing="0"
CellPadding="3" GridLines="Both" BorderWidth="1" BorderColor="black" DataKeyField="AD_TITLE">
<ItemTemplate>
<asp:LinkButton ID="lbGalleryEdit" Text="Edit" CssClass="changeLinks" CommandName="Edit" runat="server" />
<%# DataBinder.Eval(Container.DataItem, "AD_TITLE") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Textbox1" Text='<%# DataBinder.Eval(Container.DataItem, "AD_TITLE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox2" Text='<%# DataBinder.Eval(Container.DataItem, "AD_TYPE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox3" Text='<%# DataBinder.Eval(Container.DataItem, "category_id") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox4" Text='<%# DataBinder.Eval(Container.DataItem, "AD_DESCRIPTION") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox5" Text='<%# DataBinder.Eval(Container.DataItem, "area") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox6" Text='<%# DataBinder.Eval(Container.DataItem, "unit") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox7" Text='<%# DataBinder.Eval(Container.DataItem, "PRICE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox8" Text='<%# DataBinder.Eval(Container.DataItem, "WebUrl") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox9" Text='<%# DataBinder.Eval(Container.DataItem, "LOCATION") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox10" Text='<%# DataBinder.Eval(Container.DataItem, "plotname") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox11" Text='<%# DataBinder.Eval(Container.DataItem, "EMAIL_ID") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox12" Text='<%# DataBinder.Eval(Container.DataItem, "PHONENO") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:LinkButton ID="lbGalleryUpdate" Text="Update" CommandName="Update" CssClass="changeLinks" runat="server" />
<asp:LinkButton ID="lbGalleryCancel" Text="Cancel" CommandName="Cancel" CssClass="changeLinksLast"
runat="server" />
</EditItemTemplate>
</asp:datalist>
----------------------------------------------------------
please help me to trace out ...
thanks
bijesh
|
|
|
|
|
Sorry.. my mistake ..
Try again with the following code.
e.Item.FindControl("")
If it is not still working, I wanna know a few thing and will make a sample download for you.
1. Are you using VS 2003 or 2005?
2. Are those column in DataList the bounded column or unbounded?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hello
Thank you for your reply....
1. Are you using VS 2003 or 2005? <b>Ans: vs2003</b>
2. Are those column in DataList the bounded column or unbounded? <b>Ans:Bounded</b>
i try it with <b> e.Item.FindControl("")</b>
But still the same error comes......
-------------------------------------------------------------------------
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(159): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(163): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(171): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(170): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(162): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(161): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(169): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(168): 'System.EventArgs' does not contain a definition for 'Item'
C:\Inetpub\wwwroot\approvedplotfinal\classified\Youradvts.aspx.cs(167): 'System.EventArgs' does not contain a definition for 'Item'
----------------------------------------------------------------------------
<big>Then i hide(//give comment lines and try if the Datalist showing the items or not</big> <code><b> But the Error is like this ......What is my mistake, i cant recognize...???please help me to find it out.............</b></code>
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0122: 'Newclassified.Youradvts.dlGallery_cancelCommand(object, System.EventArgs)' is inaccessible due to its protection level
Source Error:
Line 7103: </tr>
Line 7104: </table>
Line 7105: <asp:datalist id="dlGallery" runat="server" OnCancelCommand="dlGallery_cancelCommand" OnUpdateCommand="dlGallery_updateCommand"
Line 7106: OnEditCommand="dlGallery_EditCommand" EditItemStyle-BackColor="lightgreen" AlternatingItemStyle-BackColor="Gainsboro"
Line 7107: HeaderStyle-BackColor="#aaaadd" Width="150px" Font-Size="8pt" Font-Name="Verdana" CellSpacing="0"
Source File: http://localhost/approvedplotfinal/classified/Youradvts.aspx Line: 7105
-----------------------------------------------------------------------------
<big><b>This is my HTML code</b></big>
<asp:datalist id=dlGallery DataKeyField="AD_TITLE" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" Width="150px" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="Gainsboro" EditItemStyle-BackColor="lightgreen" OnEditCommand="dlGallery_EditCommand" OnUpdateCommand="dlGallery_updateCommand" OnCancelCommand="dlGallery_cancelCommand" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lbGalleryEdit" Text="Edit" CssClass="changeLinks" CommandName="Edit" runat="server" />
<%# DataBinder.Eval(Container.DataItem, "AD_TITLE") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Textbox1" Text='<%# DataBinder.Eval(Container.DataItem, "AD_TITLE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox2" Text='<%# DataBinder.Eval(Container.DataItem, "AD_TYPE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox3" Text='<%# DataBinder.Eval(Container.DataItem, "category_id") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox4" Text='<%# DataBinder.Eval(Container.DataItem, "AD_DESCRIPTION") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox5" Text='<%# DataBinder.Eval(Container.DataItem, "area") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox6" Text='<%# DataBinder.Eval(Container.DataItem, "unit") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox7" Text='<%# DataBinder.Eval(Container.DataItem, "PRICE") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox8" Text='<%# DataBinder.Eval(Container.DataItem, "WebUrl") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox9" Text='<%# DataBinder.Eval(Container.DataItem, "LOCATION") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox10" Text='<%# DataBinder.Eval(Container.DataItem, "plotname") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox11" Text='<%# DataBinder.Eval(Container.DataItem, "EMAIL_ID") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:TextBox ID="Textbox12" Text='<%# DataBinder.Eval(Container.DataItem, "PHONENO") %>' CssClass="txtBoxHalf" runat="server" /><br />
<asp:LinkButton ID="lbGalleryUpdate" Text="Update" CommandName="Update" CssClass="changeLinks" runat="server" />
<asp:LinkButton ID="lbGalleryCancel" Text="Cancel" CommandName="Cancel" CssClass="changeLinksLast"
runat="server" />
</EditItemTemplate>
</asp:datalist></TD>
----------------------------------------------------------------------------
This is my aspx.cs page
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Newclassified
{
/// <summary>
/// Summary description for samble11.
/// </summary>
public class Youradvts : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList dlGallery;
protected System.Web.UI.WebControls.DataList DataList1;
DataTable dt;
SqlDataReader sdr;
public DataTable Cart;
protected System.Web.UI.WebControls.Label lblmem_id;
public DataView CartView;
connection constr=new connection();
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["DL3_ShoppingCart"] == null)
{
Cart = new DataTable();
Cart.Columns.Add(new DataColumn("AD_TITLE", typeof(string)));
Cart.Columns.Add(new DataColumn("Type", typeof(string)));
Cart.Columns.Add(new DataColumn("Category", typeof(string)));
Cart.Columns.Add(new DataColumn("Description", typeof(string)));
Cart.Columns.Add(new DataColumn("Area", typeof(string)));
Cart.Columns.Add(new DataColumn("Unit", typeof(string)));
Cart.Columns.Add(new DataColumn("Price", typeof(string)));
Cart.Columns.Add(new DataColumn("Web URL", typeof(string)));
Cart.Columns.Add(new DataColumn("Location", typeof(string)));
Cart.Columns.Add(new DataColumn("Name", typeof(string)));
Cart.Columns.Add(new DataColumn("Email ID", typeof(string)));
Cart.Columns.Add(new DataColumn("Phone No", typeof(string)));
Session["DL3_ShoppingCart"] = Cart;
// first load -- prepopulate with some data
for (int i=1; i<5; i++)
{
// dr[0] = ((int)((i%2)+1)).ToString();
// dr[1] = "Item " + i.ToString();
// dr[2] = ((double)(1.23 * (i+1))).ToString();
DataRow dr = Cart.NewRow();
dr[0] = "Title" + i.ToString();
dr[1] = "Type " + i.ToString();
dr[2] = "Category" + i.ToString();
dr[3] = "Description" + i.ToString();
dr[4] = "Area " + i.ToString();
dr[5] = "Unit" + i.ToString();
dr[6] = "Price" + i.ToString();
dr[7] = "WebURL" + i.ToString();
dr[8] = "Location"+i.ToString();
dr[9] = "Name"+i.ToString();
dr[10] = "Email ID " + i.ToString();
dr[11] = "Phone No"+i.ToString();
Cart.Rows.Add(dr);
}
}
else
Cart = (DataTable)Session["DL3_ShoppingCart"];
CartView = new DataView(Cart);
//CartView.Sort = "Item";
if (!IsPostBack)
BindList();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dlGallery.SelectedIndexChanged += new System.EventHandler(this.dlGallery_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
void BindList()
{
try
{
connection constr=new connection();
string ss=Session["uid"].ToString();
string mem_id;
string sstr1="select id from tbl_userreg where username='"+ss+"'";
sdr=constr.reader(sstr1);
while(sdr.Read())
{
mem_id=sdr["id"].ToString();
lblmem_id.Text=mem_id.ToString();
}
string str="select AD_TITLE,AD_TYPE,AD_DESCRIPTION,category_id,LOCATION,EMAIL_ID,PHONENO,DATE_POSTED from ads where member_id="+Convert.ToInt32(lblmem_id.Text.ToString())+"";
dt=new DataTable();
dt=constr.ExQselect(str);
if(dt.Rows[0].ItemArray[0].ToString()=="")
{
lblmem_id.Visible=true;
lblmem_id.Text="Please Add Your Advertisement";
}
dlGallery.DataSource=dt;
dlGallery.DataBind();
}
catch
{
lblmem_id.Visible=true;
lblmem_id.Text="Kindly Register YourSelf To ADVERTISE FREELY For 60 Days";
}
}
private void dlGallery_EditCommand(object sender, System.EventArgs e)
{
dlGallery.EditItemIndex = e.Item.ItemIndex;
BindList();
}
private void dlGallery_updateCommand(object sender, System.EventArgs e)
{
string item = ((System.Web.UI.WebControls.Label)e.Item.FindControl("Label1")).Text;
string qty = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text1")).Text;
string title = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text1")).Text;
string type= ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text2")).Text;
string category = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text3")).Text;
string description = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text4")).Text;
string area = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text5")).Text;
string unit= ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text6")).Text;
string price = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text7")).Text;
string weburl = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text8")).Text;
string location = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text9")).Text;
string name= ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text10")).Text;
string emailid = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text11")).Text;
string phoneno= ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("Text12")).Text;
// with a database, we'd use an update command. Since we're using an in-memory
// DataTable, we'll delete the old row and replace it with a new one
//remove old entry
//CartView.RowFilter = "Item='"+item+"'";
if (CartView.Count > 0) //item exists in cart
CartView.Delete(0);
CartView.RowFilter = "";
//add new entry
DataRow dr = Cart.NewRow();
dr[0] = title;
dr[1] = type;
dr[2] = category;
dr[3] = description;
dr[4] = area;
dr[5] = unit;
dr[6] = price;
dr[7] = weburl;
dr[8] = location;
dr[9] = name;
dr[10] = emailid;
dr[11] = phoneno;
Cart.Rows.Add(dr);
dlGallery.EditItemIndex = -1;
BindList();
}
private void dlGallery_cancelCommand(object sender, System.EventArgs e)
{
dlGallery.EditItemIndex = -1;
BindList();
}
-------------------------------------------------------------------------
Please help me to find out....
Thanks
Biju
|
|
|
|
|
|
hi all,
On the top 100 pages of a site I would like to add a list of pages that people who visited that page had also visited during their visit.
i will at the maximum post 5 links that was visited by the people.
Is there any way to get this kind of information?
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
anu81 wrote: I would like to add a list of pages that people who visited that page had also visited during their visit.
What do you mean by this ?
anu81 wrote: i will at the maximum post 5 links that was visited by the people.
Do you want to track the user visited pages ?
|
|
|
|
|
hi,
yes, i want to track the pages visited by the user and based on this i need to recommend the user the most visited pages.
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
|
hi,
thanks for the reply. but i don't want to know the number of visitors who visited my site.rather i would like to know the pages they visited in the site.
Hope i am clear in my explanation
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
|
once again thanks. but still the code just demonstrates only the count of visitors and not the links they visited. i tried searching in the google and found only links for storing the hit counter for the site.
Could you please guide me to any link for storing the information about the urls visited by the user for a site.
Thanks again
Regards
Anuradha
|
|
|
|
|
Below are my codes. I have created one webservice method to Upload the file.
I access this webservice in my aspx file. It compile's fine. But it always return the
result "2"
What is wrong in my code?
byte[] fileContent = null;
FileStream fStream = null;
string strPath = @"D:\XML Tutorial(Basics).doc";
string strFileName = Path.GetFileName(strPath);
int uploadStatus;
fStream = new FileStream(strPath, FileMode.Open, FileAccess.Read);
fileContent = new byte[fStream.Length];
fStream.Read(binFile, 0, (int)fStream.Length);
uploadStatus = spService1.UploadAndApproveContent(strFileName, fileContent, 1);
if (uploadStatus == 0)
Response.Write("File has been UpLoaded");
else if (uploadStatus == 2)
Response.Write("File doesn't Contain anything");
else
Response.Write("File doesn't uploaded");
[WebMethod]
public int UploadAndApproveContent(string fileName, byte[] fileContents ,int approvalStatus)
{
if (fileContents == null)
{
return 2;
}
try
{
fileName = "Tmp_" + fileName;
SPWeb site = new SPSite(srcUrl).OpenWeb();
SPFile spFile = site.GetFile(srcUrl + "/" + fileName);
SPFolder folder = site.GetFolder(srcUrl);
if (isFileExists(fileName))
{
spFile.CheckOut();
spFile.CheckedOutBy.LoginName.ToString();
}
else
{
folder.Files.Add(fileName, fileContents, true);
SPModerationInformation spModerationInformation = spFile.Item.ModerationInformation;
switch (approvalStatus)
{
case 1:
spModerationInformation.Status = SPModerationStatusType.Pending;
spModerationInformation.Comment = "Its pending";
spFile.Item.Update();
return 0;
case 2:
spModerationInformation.Status = SPModerationStatusType.Approved;
spModerationInformation.Comment = "Got the Approval";
spFile.Item.Update();
return 0;
case 3:
spModerationInformation.Status = SPModerationStatusType.Denied;
spModerationInformation.Comment = "Its Rejected";
spFile.Item.Update();
return 0;
default:
return 1;
}
}
}
catch
{
throw;
}
return 3;
}
|
|
|
|
|
Well based off your code your fileContents byte array must always be null. If you are always return 2 from your method call.
Ben
|
|
|
|
|
jayarajmrj wrote: if (fileContents == null)
{
return 2;
}
This is what is happening... The value of fileContents received by the webservice is null.
jayarajmrj wrote: fStream.Read(binFile, 0, (int)fStream.Length);
what is binFile ? Shouldn't that be: fStream.Read(fileContent, 0, (int)fStream.Length); instead?
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
By Default,when you do any update from code on sharepoint list item which has approval attached to it,it will be always be approved
|
|
|
|
|
i have two page a and b i cross from page a to page b so a is the previous page
the question IsCrossPagePostBack property
in page b in the load event
if i said [page.IsCrossPagePostBack]
mean is a is cross to page b
or mean
is b crossed from a
or what it mean
+++second question
if i want to check if page b is open throught page a or opened from it's self
md_refay
|
|
|
|
|
From MSDN:
ASP.NET provides two mechanisms for transferring control from one page to another. You can use the Transfer method to transfer processing between pages, or you can make a cross-page request by assigning a page URL to the PostBackUrl property of a button control that implements the IButtonControl interface. <br />
<br />
In either case, the PreviousPage page property will contain an object that represents the previous or originator page. If, for example, Page A posts to Page B, Page A's IsCrossPagePostBack property (accessible through the PreviousPage property) will be true and Page B's PreviousPage property will have the name of Page A.
For the second question, to check if page B is posted from itself, use the IsPostBack property.
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi
We are running an C# ASP.NET 2.0 web application connected to an SQL server 2005 database. After the application has been running for a few hours, the application begins to get timeouts while communication with the database. The database sever is still working fine(no hectic activity). I can also execute the same SQL statements in the Management Studio and they work fast. It makes no sense at all, so I restart the application by editing the web.config and restarting the application pool. The timeouts then seem to disapear.
As far as I know its not connection pooling as the number of connections to the SQL server seem to low. I also make sure all connections are closed after they are used so the standard .net connection pooling is being used properly.
What can I do to fix or further debug and find the cause of the problem as it seems to recur daily and does not seem to be related to the number of users using the application?
Thanks
|
|
|
|
|
When the timeouts start happening, have you tried using sp_who2 from the a sql query window. Perhaps for some reason one of your database queries is causing some blocking. There is a BlkBy column. If you see a number in this column it is the spid of the process that is blocking. If you are closing your connections then in must be a blocking problem.
Ben
|
|
|
|
|
Thanks.
I will give it a try as soon as the error occurs again.
Richard
|
|
|
|
|
Hi Guys,
I'm trying to get a website to run locally, but i'm having a problem. When i run the app, it loads up IE, stops debugging, and then displays a 403 error. I'm totally baffled as to what to do as if i run it in debug, it handle remote calls.
I'm running it in Cassini, on Vista, and the site requires HTTPS. The initial query string is for HTTP. Running the app without opening a page, and trying to navigate to it manually result in the same 403.
Could anyone give me some pointers as to why it won't run locally?
Cheers
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
I've created a web user control with a few properties that I want to assign to a different object during postback but it seems like the user control gets re-instantiated or something and passes back as null. What am I doing wrong? I've tried with a simpler user control and the same thing happens.
Here's the code I'm using. Hope it makes it clearer.
WebUserControl.ascx
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
<asp:button id="Button1" runat="server" text="Click" />
WebUserControl.ascx.cs
private string _Text;
public string Text // property to assign later
{
get { return _Text; }
set { _Text = value; }
}
public event EventHandler ValueChanged;
protected void OnValueChanged(EventArgs e)
{
if (ValueChanged != null)
{
ValueChanged(this, e);
}
}
protected void Button1_Click(object sender, System.EventArgs e)
{
Text = TextBox1.Text; // assign property value
OnValueChanged(e); // raise event
}
Then, after dropping the user control onto the web form...
Default.aspx
<uc1:webusercontrol id="WebUserControl1" runat="server" onvaluechanged="WebUserControl1_ValueChanged" />
<br />
<br />
<asp:button id="btnAssign" runat="server" onclick="btnAssign_Click" text="Assign Value" />
So far so good...
Default.aspx.cs
string _MyText; // want to assign to this
protected void WebUserControl1_ValueChanged(object sender, EventArgs e)
{
btnAssign.Text = WebUserControl1.Text; // This works
}
protected void btnAssign_Click(object sender, EventArgs e)
{
_MyText = WebUserControl1.Text; //This says WebUserControl1.Text = null
}
I'm sure it's something really stupid that I'm forgetting to do or maybe the way I've gone about it but it's got me stuck & I'd really appreciate someone telling me where I've missed it.
Thanks.
|
|
|
|
|
I figured it out - I'm getting it to work using viewstate.
Is this good practice or is there a better way?
|
|
|
|
|