Click here to Skip to main content
15,914,608 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: ImageButton command argument Pin
minhpc_bk23-Apr-06 21:16
minhpc_bk23-Apr-06 21:16 
GeneralRe: ImageButton command argument Pin
TheEagle24-Apr-06 4:54
TheEagle24-Apr-06 4:54 
GeneralRe: ImageButton command argument Pin
minhpc_bk24-Apr-06 15:54
minhpc_bk24-Apr-06 15:54 
GeneralRe: ImageButton command argument Pin
TheEagle24-Apr-06 16:42
TheEagle24-Apr-06 16:42 
GeneralRe: ImageButton command argument Pin
minhpc_bk24-Apr-06 16:54
minhpc_bk24-Apr-06 16:54 
GeneralRe: ImageButton command argument Pin
TheEagle24-Apr-06 23:09
TheEagle24-Apr-06 23:09 
GeneralRe: ImageButton command argument Pin
minhpc_bk24-Apr-06 23:36
minhpc_bk24-Apr-06 23:36 
GeneralRe: ImageButton command argument Pin
TheEagle29-Apr-06 4:51
TheEagle29-Apr-06 4:51 
Hi..Sorry for being too late.
After i added:
using System.Web.UI;
The build error disappeared but after i uploaded(updated) the project i got the error message:

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


Line 12: <TR>
Line 13: <TD vAlign="middle" align="center">
Line 14: <asp:ImageButton id=ImageButton1 runat="server" OnCommand="gogof" ImageUrl='<%#"~/Epictures/"+DataBinder.Eval(Container.DataItem,"ProjectImage")%>' CommandArgument='<%#GenerateDataBinders(Container.DataItem,Container.ItemIndex)%>' CommandName="topf" BorderStyle="Solid" BorderColor="green">
Line 15: </asp:ImageButton></TD>
Line 16: </TR>


Source File: C:\Sites\Single25\nabeel1eagle\webroot\UserControls\FieldProjectsList.ascx Line: 14


The UserControl code:
namespace EProjects.UserControls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for FieldProjectsList.
/// </summary>
public class FieldProjectsList : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataList lProjects;

private void Page_Load(object sender, System.EventArgs e)
{
string searchString=Request.QueryString["SearchString"];
string allWords=Request.QueryString["AllWords"];
string pageNumber=Request.QueryString["PageNumber"];
if(searchString!=null && searchString!="")
{

allWords=Request.QueryString["AllWords"];
pageNumber=Request.QueryString["PageNumber"];
lProjects.DataSource=catalog.SearchProject(searchString,allWords,pageNumber,System.Threading.Thread.CurrentThread.CurrentCulture.Name);


lProjects.DataBind();
}
else
{
BindData();
}


}

#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.lProjects.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.lProjects_ItemDataBound);
this.lProjects.SelectedIndexChanged += new System.EventHandler(this.lProjects_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
public void gogof(object s,CommandEventArgs e)
{string searchString=Request.QueryString["SearchString"];
// string allWords=Request.QueryString["AllWords"];
/* if(searchString!=null)
{
lProjects.DataSource=catalog.SearchProject(searchString,allWords);
lProjects.DataBind();
}
else
BindData();*/
//string fieldNO=Request.QueryString["FieldNO"];
string fieldNO=Request.QueryString["FieldNO"];
string fieldIndex=Request.QueryString["FieldIndex"];
string allWords=Request.QueryString["AllWords"];
string pageNumber=Request.QueryString["PageNumber"];
//string allWords=Request.QueryString["AllWords"];
/* if(searchString!=null)
{
lProjects.DataSource=catalog.SearchProject(searchString,allWords,pageNumber,System.Threading.Thread.CurrentThread.CurrentCulture.Name);
lProjects.DataBind();
}
else
BindData();*/
string argu=e.CommandArgument.ToString();
string[] argss=argu.Split(',');
string projectNO;
string projectIndex;

if(e.CommandName=="topf")
{

// Trace.Warn("ProjectProblem",projectNO);
if(searchString!=null && searchString!="")
{
Trace.Warn("FieldProblem",argu);
projectNO=argss[0];
fieldNO=argss[1];
Response.Redirect("default.aspx?FieldNO="+fieldNO+"&ProjectNO="+projectNO);
}
else
{

//Trace.Warn("ProjectNO=",Convert.ToString(argu.IndexOf("+")+1));
// Trace.Warn("IndexProblem=",Convert.ToString(argu.IndexOf("_")));
fieldNO=Request.QueryString["FieldNO"];
fieldIndex=Request.QueryString["FieldIndex"];
projectIndex=argss[1];
projectNO=argss[0];
Response.Redirect("default.aspx?FieldNO="+fieldNO+"&FieldIndex="+fieldIndex+"&ProjectNO="+projectNO+"&ProjectIndex="+projectIndex);
}
}
}
public void BindData()
{
string fieldNO=Request.QueryString["FieldNO"];
lProjects.DataSource=EProjects.AdministratorSite.AdminCatalog.GetFieldProjects(fieldNO,System.Threading.Thread.CurrentThread.CurrentCulture.Name);
lProjects.DataBind();
}

private void lProjects_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{

}

private void lProjects_SelectedIndexChanged(object sender, System.EventArgs e)
{

}
public string GenerateDataBinders(object dataItem,int Index)
{string searchString=Request.QueryString["SearchString"];
string projectIndex;
string projectNO;
string fieldNO;
if(searchString!=null && searchString!="")
{
projectNO=(string)DataBinder.Eval(dataItem,"ProjectNO");
fieldNO=(string)DataBinder.Eval(dataItem,"FieldNO");
return projectNO+","+fieldNO;
}
else
{
Trace.Warn("PProjectNO=",Convert.ToString(Index));
projectNO=(string)DataBinder.Eval(dataItem,"ProjectNO");
projectIndex=Convert.ToString(Index);
return projectNO+","+projectIndex;
}
}
}
}

its HTML :

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="FieldProjectsList.ascx.cs" Inherits="EProjects.UserControls.FieldProjectsList" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<asp:datalist id="lProjects" Width="100%" RepeatColumns="2" runat="server">
<ItemTemplate>
<TABLE height="100%" cellPadding="0" width="100%">
<TR>
<TD align="center">
<asp:Label id="Label1" NAME="Label1" Runat="server" CssClass="labelstyle">
<%#DataBinder.Eval(Container.DataItem,"ProjectName")%>
</asp:Label><BR>
</TD>
</TR>
<TR>
<TD vAlign="middle" align="center">
<asp:ImageButton id=ImageButton1 runat="server" OnCommand="gogof" ImageUrl='<%#"~/Epictures/"+DataBinder.Eval(Container.DataItem,"ProjectImage")%>' CommandArgument='<%#GenerateDataBinders(Container.DataItem,Container.ItemIndex)%>' CommandName="topf" BorderStyle="Solid" BorderColor="green">
</asp:ImageButton></TD>
</TR>
<TR>
<TD align="center">
<asp:Label id="Label2" NAME="Label2" Runat="server">
<%#DataBinder.Eval(Container.DataItem,"ProjectDescription")%>
</asp:Label><BR>
</TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:datalist>


I think that the problem in using the Container.ItemIndex.I have made it (int) and beforethis i tried making it object but the same error appeared.

You have helped me all the time thank you very much my teacher.Smile | :)

GeneralRe: ImageButton command argument Pin
TheEagle1-May-06 17:23
TheEagle1-May-06 17:23 
Questionproblem with validation control Pin
sudharsong23-Apr-06 20:01
sudharsong23-Apr-06 20:01 
AnswerRe: problem with validation control Pin
minhpc_bk23-Apr-06 20:44
minhpc_bk23-Apr-06 20:44 
GeneralRe: problem with validation control Pin
sudharsong23-Apr-06 20:48
sudharsong23-Apr-06 20:48 
AnswerRe: problem with validation control Pin
HimaBindu Vejella23-Apr-06 21:01
HimaBindu Vejella23-Apr-06 21:01 
GeneralRe: problem with validation control Pin
sudharsong23-Apr-06 21:14
sudharsong23-Apr-06 21:14 
QuestionHow to insert to SQL Express Edition from a textbox and a SAVE button? Pin
tanpanjang23-Apr-06 17:42
tanpanjang23-Apr-06 17:42 
AnswerRe: How to insert to SQL Express Edition from a textbox and a SAVE button? Pin
minhpc_bk23-Apr-06 20:40
minhpc_bk23-Apr-06 20:40 
QuestionInsert multiple records Pin
tanpanjang23-Apr-06 17:34
tanpanjang23-Apr-06 17:34 
QuestionDynamically change Flash movies......... Pin
daviiie23-Apr-06 13:13
daviiie23-Apr-06 13:13 
AnswerRe: Dynamically change Flash movies......... Pin
minhpc_bk23-Apr-06 20:34
minhpc_bk23-Apr-06 20:34 
Questionhi ans my question... Pin
muthukumaar23-Apr-06 6:03
muthukumaar23-Apr-06 6:03 
AnswerRe: hi ans my question... Pin
Roshan P Mohammed23-Apr-06 19:00
Roshan P Mohammed23-Apr-06 19:00 
AnswerRe: hi ans my question... Pin
minhpc_bk23-Apr-06 20:27
minhpc_bk23-Apr-06 20:27 
AnswerRe: hi ans my question... Pin
HimaBindu Vejella23-Apr-06 21:18
HimaBindu Vejella23-Apr-06 21:18 
QuestionUser Login Pin
Sean8923-Apr-06 5:40
Sean8923-Apr-06 5:40 
AnswerRe: User Login Pin
minhpc_bk23-Apr-06 20:19
minhpc_bk23-Apr-06 20:19 

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.