473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem in displaying

I Got a prob in repeater . The DoThis method is not firing . wenever i comment QueryString code it works properly. I m not getting it. In Default.aspx, datalist I added OnItemCommand ="DoThis". Check out this code


Default.aspx.cs
-----------------------------
protected void Page_Load( object Sender ,EventArgs e)
{
if (Request.QueryString["viewList"] != null)
{
if (Request.QueryString["viewList"] == "1")
{
mvUser.SetActiveView(viewFile);
DataSet ds = new DataSet();
lblTest.Text = Request.QueryString["viewList"];
FillRepeater();
}
}

}

In ProductLogin
--------------------------

Response.Redirect("Default.aspx?viewList=1");

Default.aspx
-------------------------
<asp:View ID="viewProducts" runat="server">
<%--<asp:UpdatePanel ID="UpdatePanel14" runat="server">
<ContentTemplate>--%>
<asp:Label ID="Label3" runat="server" Text=""></asp:Label>
<asp:Repeater ID="rptProducts" runat="server" EnableViewState="true" OnItemCommand="Create" >
<HeaderTemplate >
<asp:Label ID="lblHeader" runat="server" Text=""></asp:Label>
</HeaderTemplate>
<ItemTemplate >
<table bgcolor="#FFFBFF" style="border-bottom: solid 1px Lavender; border-left: solid 1px Lavender;
border-right: solid 1px Lavender; border-top: solid 1px Lavender">
<tr style="border-bottom:solid 1px LightGrey;border-left:solid 1px LightGrey;
border-right:solid 1px Red;border-top:solid 1px LightGrey">
<td align="left" valign="top" style="border-right:solid 1px LightGrey;border-bottom:solid 1px LightGrey;border-left:solid 1px LighGrey;border-top:solid 1px LighGrey">
<tr><td bgcolor="White" style="border-right: solid 1px LightGrey; border-bottom: solid 1px LightGrey;
border-left: solid 1px LighGrey; border-top: solid 1px LighGrey">
<asp:ImageMap ID="img1" runat="server" Width="150px" Height="150px" ImageUrl="<%#Bind('Product_image')%>"></asp:ImageMap>
</td>
<td bgcolor=Honeydew >
<asp:DataList ID="dlData" runat="server" DataKeyField="prod_doc_id" EnableViewState=true RepeatColumns=3 RepeatDirection=Horizontal OnItemCommand="DoThis">
<ItemTemplate>
<table align="right" style="vertical-align: top">
<tr align="left" valign="top">
<td >
<asp:HiddenField ID="hf1" runat="server" Value="<%#Bind('prod_doc_id')%>" />
<asp:LinkButton ID="lnbProddocs" CommandName="Select" Text="<%#Bind('doc_id')%>" runat="server">
</asp:LinkButton>
</td>
</tr>
</table>
</td>
<td>
</td>
</ItemTemplate>
</asp:DataList></td>


protected void DoThis(object s, DataListCommandEventArgs e)
{

string key = ((DataList)s).DataKeys[e.Item.ItemIndex].ToString();
hf1.Value = key;
DataSet ds = ConDB.getDocLoc(key);
DataTable dt = ds.Tables[0];
try
{
string fileName = dt.Rows[0]["doc_name"].ToString();
string fileLoc = dt.Rows[0]["doc_loc"].ToString();


if (fileName == "" && fileLoc == "")
{

Response.Write("<script>alert('Not Applicable for this product');</script>");
"alert", "alert('The passwords did not match');");
}
else if (fileName == "Not available")
{

Response.Write("<script>alert('Currently Not Available');</script>");
}
else
{
DirectoryInfo dir = new DirectoryInfo(fileLoc);
DataTable FilesTab = new DataTable();
DataColumn dc0 = new DataColumn("TYPE");
DataColumn dc1 = new DataColumn("NAME");
DataColumn dc2 = new DataColumn("PATH");
FilesTab.Columns.Add(dc0);
FilesTab.Columns.Add(dc1);
FilesTab.Columns.Add(dc2)



FileInfo fInfo = new FileInfo(fileName);
lblTest.Text = "Hello" + fileName + fileLoc;
string fExt = fInfo.Extension.ToUpper();
string url = fileLoc + fileName;
string path = Path.GetFullPath(url);
WriteFile(path);

}

}
catch (Exception exc)
{
lblTest.Text = "The requested file is currently not accessible";
}
}
Jun 6 '08 #1
1 1000
JKing
1,206 Expert 1GB
Hey there,

I took a quick glance at your problem. I think DoThis is still firing. However it causes a postback and thus reloads the page each time firing off your load event. Now I'm assuming you're using lblTest as a visual cue. If this is the case the page would appear to be unchanged each time as you set the text for lblTest in the load event.

If this is indeed the cause of your problems the fix would be to use the IsPostback Property of the page to determine if it is the first time the page has been opened or if the user has triggered a postback.

Example:
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load( object Sender ,EventArgs e)
  2. {
  3.      if (!IsPostback)
  4.      {
  5.            //put querystring code here
  6.      }
  7. }
  8.  
Hope this helps!
Jared
Jun 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying...
8
by: Ramesh | last post by:
hi, My C# application displaying correctly in IE, But in netscape all input controls (text box, dblist, drop down list and etc.,) disappered. Only lables are displaying. The value inside the drop...
2
by: Balamurali C | last post by:
Hi All I'm having one problem, since im debuging this last one week I'm not able to do. Problem: In my webage I have two Frames(top & bottom) in the top frame I'm displaying some...
1
by: johnVarma | last post by:
Hi All, Iam facing a problem with bar chart using coldFusion. if there is only one <cfchartseries> tag then the seriesLabel attribute is not displaying instead of that the items of the...
0
by: paragguptaiiita | last post by:
I have one problem regarding displaying text from XML file. I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.