Click here to Skip to main content
15,913,453 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to use Edit and update in DataList??? Pin
Michael Sync17-Aug-07 2:38
Michael Sync17-Aug-07 2:38 
GeneralRe: How to use Edit and update in DataList??? Pin
bijeshputhalath17-Aug-07 5:50
bijeshputhalath17-Aug-07 5:50 
GeneralRe: How to use Edit and update in DataList??? Pin
Michael Sync17-Aug-07 16:37
Michael Sync17-Aug-07 16:37 
GeneralRe: How to use Edit and update in DataList??? Pin
bijeshputhalath17-Aug-07 20:36
bijeshputhalath17-Aug-07 20:36 
GeneralRe: How to use Edit and update in DataList??? Pin
Michael Sync17-Aug-07 22:14
Michael Sync17-Aug-07 22:14 
GeneralRe: How to use Edit and update in DataList??? Pin
bijeshputhalath17-Aug-07 22:41
bijeshputhalath17-Aug-07 22:41 
GeneralRe: How to use Edit and update in DataList??? Pin
Michael Sync18-Aug-07 8:05
Michael Sync18-Aug-07 8:05 
GeneralRe: How to use Edit and update in DataList??? Pin
bijeshputhalath19-Aug-07 1:25
bijeshputhalath19-Aug-07 1:25 
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
GeneralRe: How to use Edit and update in DataList??? Pin
Michael Sync19-Aug-07 4:52
Michael Sync19-Aug-07 4:52 
Questionrecommendation engine Pin
anu8117-Aug-07 1:42
anu8117-Aug-07 1:42 
AnswerRe: recommendation engine Pin
N a v a n e e t h17-Aug-07 2:32
N a v a n e e t h17-Aug-07 2:32 
GeneralRe: recommendation engine Pin
anu8117-Aug-07 2:47
anu8117-Aug-07 2:47 
GeneralRe: recommendation engine Pin
sathish s17-Aug-07 3:13
sathish s17-Aug-07 3:13 
GeneralRe: recommendation engine Pin
anu8117-Aug-07 3:17
anu8117-Aug-07 3:17 
GeneralRe: recommendation engine Pin
sathish s17-Aug-07 3:37
sathish s17-Aug-07 3:37 
GeneralRe: recommendation engine Pin
anu8117-Aug-07 4:10
anu8117-Aug-07 4:10 
QuestionUrgent WebService Pin
jayarajmrj17-Aug-07 1:24
jayarajmrj17-Aug-07 1:24 
AnswerRe: Urgent WebService Pin
kubben17-Aug-07 1:56
kubben17-Aug-07 1:56 
AnswerRe: Urgent WebService Pin
Talal Sultan17-Aug-07 2:28
Talal Sultan17-Aug-07 2:28 
AnswerRe: Urgent WebService Pin
Member 144327816-Oct-09 3:24
Member 144327816-Oct-09 3:24 
QuestionIsCrossPagePostBack Pin
md_refay17-Aug-07 1:08
md_refay17-Aug-07 1:08 
AnswerRe: IsCrossPagePostBack Pin
Talal Sultan17-Aug-07 2:33
Talal Sultan17-Aug-07 2:33 
QuestionTimeouts after application running for a while Pin
Manime17-Aug-07 0:54
Manime17-Aug-07 0:54 
AnswerRe: Timeouts after application running for a while Pin
kubben17-Aug-07 1:49
kubben17-Aug-07 1:49 
GeneralRe: Timeouts after application running for a while Pin
Manime17-Aug-07 1:56
Manime17-Aug-07 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.