Show 3rd div on the basis of timer - c#

I have three div which each is shown within a gap of 3 seconds interval. On Page_load it shows first div data, then after 3 seconds, it shows another div data.
So,
now what I want is, Now after more 3 seconds, I want to show the third div data.
Here is my simple HTML with TIMER
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<table style="width: 100%; text-align: center" border="1" runat="server" id="tbl1Details">
<colgroup>
<col width="5%" />
<col width="45%" />
</colgroup>
<tr>
<td colspan="3">
<asp:Label ID="lblpltfrm_Number" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
SR.
</td>
<td>
Stop
</td>
<td>
Time
</td>
</tr>
<tr>
<td id="tTime" runat="server">
<div id="list" runat="server">
</div>
</td>
<td>
<table style="width: 100%">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<tr>
<td style="text-align: left">
<div id="dv_FromStop" runat="server">
</div>
</td>
<td style="text-align: left">
<div id="Dv_ToStop" runat="server">
</div>
</td>
</tr>
</table>
</td>
<td>
<div id="dv_Time" runat="server">
</div>
</td>
</tr>
</table>
<!--2nd Screen-->
<table style="width: 100%; text-align: center" border="1" runat="server" id="tbl2Details"
visible="false">
<colgroup>
<col width="5%" />
<col width="45%" />
</colgroup>
<tr>
<td colspan="3">
<asp:Label ID="lbl2ndpltfrm" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
SR.
</td>
<td>
Stop
</td>
<td>
Time
</td>
</tr>
<tr>
<td>
<div id="dv2SRNo" runat="server">
</div>
</td>
<td>
<table style="width: 100%">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<tr>
<td style="text-align: left">
<div id="dv2From_Stop" runat="server">
</div>
</td>
<td style="text-align: left">
<div id="dv2ToStop" runat="server">
</div>
</td>
</tr>
</table>
</td>
<td>
<div id="dv2Time" runat="server">
</div>
</td>
</tr>
</table>
<table id="tbl3Details" style="width: 100%; text-align: center" border="1" runat="server">
<colgroup>
<col width="5%" />
<col width="45%" />
</colgroup>
<tr>
<td colspan="3">
<asp:Label ID="lbl3rdpltfrm" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
SR.
</td>
<td>
Stop
</td>
<td>
Time
</td>
</tr>
<tr>
<td>
<div id="dv3SRNo" runat="server">
</div>
</td>
<td>
<table style="width: 100%">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<tr>
<td style="text-align: left">
<div id="dv3From_Stop" runat="server">
</div>
</td>
<td style="text-align: left">
<div id="dv3To_Stop" runat="server">
</div>
</td>
</tr>
</table>
</td>
<td>
<div id="dv3Time" runat="server">
</div>
</td>
</tr>
</table>
<asp:Timer ID="Timer1" runat="server" OnTick="GetTime2" Interval="3000" />
</ContentTemplate>
</asp:UpdatePanel>
Now main thing which handles is the code behind of this:-
Have a look
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
GetPlt1Details();
Session["NextPlatForm"] = 1;
}
}
protected void GetPlt1Details()
{
lblpltfrm_Number.Text = "PlatForm 1";
list.InnerHtml = "";
dv_FromStop.InnerHtml = "";
Dv_ToStop.InnerHtml = "";
dv_Time.InnerHtml = "";
int svalue = Convert.ToInt32(Session["ReloadValue"]);
DataTable obj_Dt = new DataTable();
OracleConnection obj_Connection = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OracleConn"].ToString());
string Query = "Select x.SR_NO,x.FROM_STOP,x.TO_STOP,x.ORIGIN_STOP_TIME from XXACL_PN_BUS_TIMETABLE x WHERE SCREEN_NUMBER=1";
using (OracleCommand obj_Command = new OracleCommand(Query))
{
OracleDataAdapter obj_Adapter = new OracleDataAdapter(obj_Command);
obj_Command.Connection = obj_Connection;
obj_Adapter.SelectCommand = obj_Command;
obj_Adapter.Fill(obj_Dt);
int Count = obj_Dt.Rows.Count;
for (int i = 0; i < obj_Dt.Rows.Count; i++)
{
if (i < 2)
{
list.InnerHtml = list.InnerHtml + "<br />" +
obj_Dt.Rows[i]["SR_NO"];
dv_FromStop.InnerHtml = dv_FromStop.InnerHtml + "<br />" +
obj_Dt.Rows[i]["FROM_STOP"];
Dv_ToStop.InnerHtml = Dv_ToStop.InnerHtml + "<br />" +
obj_Dt.Rows[i]["TO_STOP"];
dv_Time.InnerHtml = dv_Time.InnerHtml + "<br />" +
obj_Dt.Rows[i]["ORIGIN_STOP_TIME"];
}
else
{
Session["NextPlatForm"] = 1;
Session["A"] = "PlatForm 1";
dv2SRNo.InnerHtml = dv2SRNo.InnerHtml + "<br />" +
obj_Dt.Rows[i]["SR_NO"];
dv2From_Stop.InnerHtml = dv2From_Stop.InnerHtml + "<br />" +
obj_Dt.Rows[i]["FROM_STOP"];
dv2ToStop.InnerHtml = dv2ToStop.InnerHtml + "<br />" +
obj_Dt.Rows[i]["TO_STOP"];
dv2Time.InnerHtml = dv2Time.InnerHtml + "<br />" +
obj_Dt.Rows[i]["ORIGIN_STOP_TIME"];
}
}
}
}
protected void GetTime2(object sender, EventArgs e)
{
int pvalue = Convert.ToInt32(Session["NextPlatForm"]);
if (pvalue != 2)
{
tbl1Details.Visible = false;
tbl2Details.Visible = true;
string a = string.Empty;
a = Convert.ToString(Session["A"]);
if (string.IsNullOrEmpty(a) == false)
{
lbl2ndpltfrm.Text = a;
}
}
else
{
tbl1Details.Visible = true;
tbl2Details.Visible = false;
lblpltfrm_Number.Text = "PlatForm 2";
list.InnerHtml = "";
dv_FromStop.InnerHtml = "";
Dv_ToStop.InnerHtml = "";
dv_Time.InnerHtml = "";
OracleConnection obj_Connection = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OracleConn"].ToString());
string Query2 = "Select x.SR_NO,x.FROM_STOP,x.TO_STOP,x.ORIGIN_STOP_TIME from XXACL_PN_BUS_TIMETABLE x WHERE SCREEN_NUMBER=2";
DataTable obj_Dt = new DataTable();
using (OracleCommand obj_Command = new OracleCommand(Query2))
{
OracleDataAdapter obj_Adapter = new OracleDataAdapter(obj_Command);
obj_Command.Connection = obj_Connection;
obj_Adapter.SelectCommand = obj_Command;
obj_Adapter.Fill(obj_Dt);
int Count = obj_Dt.Rows.Count;
for (int i = 0; i < obj_Dt.Rows.Count; i++)
{
list.InnerHtml = list.InnerHtml + "<br />" +
obj_Dt.Rows[i]["SR_NO"];
dv_FromStop.InnerHtml = dv_FromStop.InnerHtml + "<br />" +
obj_Dt.Rows[i]["FROM_STOP"];
Dv_ToStop.InnerHtml = Dv_ToStop.InnerHtml + "<br />" +
obj_Dt.Rows[i]["TO_STOP"];
dv_Time.InnerHtml = dv_Time.InnerHtml + "<br />" +
obj_Dt.Rows[i]["ORIGIN_STOP_TIME"];
}
}
}
Session["NextPlatForm"] = 2;
}
Now, With respect to this, how can I show the third div data

Related

ASP.Net Form submit

I have a search form that is fired from my grid view select button. It works fine when it loads as in the fields fill up with the selected row details as expected but when I change any field and click on update record it does not take the updated values that I just typed into the text box but seems to resave the original values . Please help
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Search_Reporters : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Ingest;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
//txt_rname.Enabled = false;
// txt_rmobile.Enabled = false;
// txt_remail.Enabled = false;
con.Open();
// string qry = "select * from Reporter where Reporter_ID= " + DropDownList1.SelectedValue + "";
lbl_1.Text = Session["id"].ToString();
string qry = "select * from Reporter where Reporter_ID= " + Session["id"] + " ";
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt); // table data-> data table
con.Close();
txt_rname.Text = dt.Rows[0][1].ToString();
txt_remail.Text = dt.Rows[0][2].ToString();
txt_rmobile.Text = dt.Rows[0][3].ToString();
}
protected void btn_edit_Click(object sender, EventArgs e)
{
txt_rname.Enabled = true;
txt_rmobile.Enabled = true;
txt_remail.Enabled = true;
lbl_remark.Text = "";
}
protected void btn_Save_Click(object sender, EventArgs e)
{
con.Open();
string qry = "update Reporter set Reporter_Name ='" + txt_rname.Text + "',Reporter_Email='" + txt_remail.Text + "',Reporter_Mobile = '" + txt_rmobile.Text + "' where Reporter_ID = " +lbl_1.Text+ "";
SqlCommand cmd = new SqlCommand(qry, con);
int x = cmd.ExecuteNonQuery();
if (x == 1)
{
//lbl_remark.Text = "Updated Successfully";
Response.Redirect("Reporters_remarks.aspx");
}
else
{
lbl_remark.Text = "error";
}
con.Close();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
lbl_remark.Text = "";
txt_rname.Text = "";
txt_remail.Text = "";
txt_rmobile.Text = "";
con.Open();
string qry = "select * from Reporter where Reporter_ID= " + DropDownList1.SelectedValue + "";
//string qry = "select * from Reporter where Reporter_ID= "+Session["id"]+" ";
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt); // table data-> data table
con.Close();
if (dt.Rows.Count == 0)
{
lbl_remark.Text = "User Not Found";
}
else
{
txt_rname.Text = dt.Rows[0][1].ToString();
txt_remail.Text = dt.Rows[0][2].ToString();
txt_rmobile.Text = dt.Rows[0][3].ToString();
}
}
}
HTML Code
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Reporters_Search.aspx.cs" Inherits="Search_Reporters" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
text-align: center;
}
.style3
{
text-align: right;
width: 648px;
}
.style4
{
text-align: center;
width: 648px;
}
.style5
{
text-decoration: underline;
font-size: larger;
}
.style6
{
text-align: center;
height: 17px;
}
.style7
{
height: 17px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td colspan="2" style="text-align: center" class="style5">
<strong>Reporter Search</strong></td>
</tr>
<tr>
<td class="style4">
</td>
<td>
</td>
</tr>
<tr>
<td class="style4" style="text-align: right">
Reporter ID:</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="Reporter_ID"
DataValueField="Reporter_ID"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:IngestConnectionString %>"
SelectCommand="SELECT [Reporter_ID] FROM [Reporter] ORDER BY [Reporter_ID]">
</asp:SqlDataSource>
<asp:Button ID="btn_edit" runat="server" Text="Edit" Width="60px"
onclick="btn_edit_Click" />
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbl_1" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
Reporter Name :</td>
<td>
<asp:TextBox ID="txt_rname" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
</td>
</tr>
<tr>
<td class="style3">
Reporter Email :</td>
<td>
<asp:TextBox ID="txt_remail" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
</td>
</tr>
<tr>
<td class="style3">
Reporter Mobile :</td>
<td>
<asp:TextBox ID="txt_rmobile" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style6">
</td>
<td class="style7">
</td>
</tr>
<tr>
<td class="style6" colspan="2">
<asp:Label ID="lbl_remark" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style6">
</td>
<td class="style7">
</td>
</tr>
<tr>
<td class="style2" colspan="2">
<asp:Button ID="btn_Save" runat="server" style="text-align: center" Text="Update Record"
Width="120px" onclick="btn_Save_Click" />
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Thanks Pradeep. The following code fixed my problem
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack )
{
txt_rname.Enabled = false;
txt_rmobile.Enabled = false;
txt_remail.Enabled = false;
con.Open();
// string qry = "select * from Reporter where Reporter_ID= " + DropDownList1.SelectedValue + "";
lbl_1.Text = Session["id"].ToString();
string qry = "select * from Reporter where Reporter_ID= " + Session["id"] + " ";
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt); // table data-> data table
con.Close();
txt_rname.Text = dt.Rows[0][1].ToString();
txt_remail.Text = dt.Rows[0][2].ToString();
txt_rmobile.Text = dt.Rows[0][3].ToString();
}
else
{
}
}

Table paging in asp.net html table

Hi guys is there a way where I can have a paging in my table?
My table is coded like this in html.
<table width="100%" id="tbl_Delivered">
<tr>
<td width="30%">
</td>
<td width="45%" class="GRIDVIEW_TITLE">
<asp:Label ID="Label5" runat="server" Text="DELIVERED"></asp:Label>
</td>
<td>
</td>
</tr>
<tr >
<td width="30%">
</td>
<td width="45%">
<div id="Delivered" runat="server">
</div>
</td>
<td width="45%">
</td>
</tr>
</table>
Then I have a stored procedure that will place another series of td's in
<div id="Delivered" runat="server">
</div>
Part of my stored procedure is this
DECLARE #DELIVERED VARCHAR(MAX)
SELECT #DELIVERED = ''
SELECT ALL
#DELIVERED = #DELIVERED + '<TR class="GRIDVIEW_DETAILS">' +
'<TD WIDTH ="100" ALIGN="LEFT">'+RefNumber+'</TD>' +
'<TD WIDTH ="100" ALIGN="LEFT">' + airwaybillno + '</TD>' +
'<TD WIDTH ="250" ALIGN="LEFT">' + RTRIM(UPPER(deliverto)) + '</TD>' +
'</TR>'
FROM #temp_delivered
--ORDER BY deliverdate DESC
SET #DELIVERED =
'<TABLE WIDTH="100%">' +
'<TR class="GRIDVIEW" ><TD >REFERENCE #</TD><TD>AIRWAYBILL #</TD><TD ALIGN="LEFT">DELIVER TO</TD></TR>' +
+ #DELIVERED +
'</TABLE>'
select #DELIVERED AS HTML from #temp_delivered
Then I have a c# code to append my html code from stored procedure to the webpage
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dsView = dm.ViewDelivered(Session["Username"].ToString());
//gridsummary.DataSource = dsView.Tables[0];
//gridsummary.DataBind();
#region old
string sDelivered = string.Empty;
DataTable dt = new DataTable();
dt = dsView.Tables[0];
List<string> slistPostal = new List<string>();
foreach (DataRow dr in dt.Rows)
{
if (dr[0].ToString() == "DELIVERED")
{
sDelivered = dr["HTML"].ToString();
Delivered.InnerHtml = sDelivered;
}
}
#endregion
}
}
I am loading many data so I want to have a paging in my table, is there any way to do that? Thanks in advance.
For Tomer Klein this is the error

Adding 'rolling numbers' for repeater control, Paging asp.net c#

I am using repeater control and showing paging '<< Previous next >>' it is working fine.
But i want to show links (rolling numbers) in between like below:
Previous << 1 2 3 4 5 next >>
have a look this picture for idea.
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table border="1" style="border-color: #336699;" cellspacing="0">
<tr style="background-color:#336699; color:White;">
<td>Product ID</td>
<td>Product Name</td>
<td>Unit Price</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("ProductID") %></td>
<td><%# Eval("ProductName") %></td>
<td><%# Eval("UnitPrice") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<div> <table width="500px" border="0" cellspacing="5" cellpadding="5">
<tr>
<td width="25%"> <asp:Label ID="Label2" runat="server" />
</td>
<td width="25%"><asp:HyperLink ID="linkPrev" runat="server">« Previous</asp:HyperLink>
</td>
<td width="25%"><asp:HyperLink ID="linkNext" runat="server">Next »</asp:HyperLink></td>
<td width="25%"><asp:Label ID="Label1" runat="server" /> </td>
</tr>
</table> </div>
c#
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from Products", con);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
con.Close();
DataTable table = new DataTable();
da.Fill(table);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = table.DefaultView;
pds.AllowPaging = true;
pds.PageSize = 10;
int currentPage;
if (Request.QueryString["page"] != null)
{
currentPage = Int32.Parse(Request.QueryString["page"]);
}
else
{
currentPage = 1;
}
pds.CurrentPageIndex = currentPage - 1;
Label1.Text = "Page " + currentPage + " of " + pds.PageCount;
Label2.Text = "Results" + pds.DataSourceCount;
if (!pds.IsFirstPage)
{
linkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (currentPage - 1);
}
if (pds.IsFirstPage)
{
linkPrev.Visible = false;
linkPrev.Style["display"] = "block";
}
if (!pds.IsLastPage)
{
linkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (currentPage + 1);
}
if (pds.IsLastPage)
{
linkNext.Visible = false;
linkPrev.Style["display"] = "block";
}
Repeater1.DataSource = pds;
Repeater1.DataBind();
}
}

Having problems in accessing textbox in listview

I am getting an error("input string was not in a correct format") every time I click the lnkUpdate button. Am i missing something? I can't find what's wrong with the codes in the updating event
aspx
<table class="table table-bordered table-hover table-responsive">
<thead>
<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Received</th>
<th>Remaining</th>
<th>Ordered</th>
<th></th>
</tr>
</thead>
<tbody>
<asp:ListView ID="lvSODetails" runat="server"
onitemcanceling="lvSODetails_ItemCanceling"
onitemediting="lvSODetails_ItemEditing"
onitemupdating="lvSODetails_ItemUpdating" >
<ItemTemplate>
<tr>
<td><%# Eval("ProductID") %></td>
<td><%# Eval("ProductName") %></td>
<td><%# Eval("Received") %></td>
<td><%# Eval("Remaining")%></td>
<td><%# Eval("Quantity") %></td>
<td>
<asp:LinkButton ID="lnkEdit" runat="server"
class="glyphicon glyphicon-pencil" CommandName="Edit" />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<asp:Panel ID="pnlDetails" runat="server" DefaultButton="lnkUpdate">
<tr>
<td><asp:Label ID="lblID" runat="server" Text='<%# Eval("ProductID") %>' /></td>
<td><%# Eval("ProductName") %></td>
<td><asp:TextBox ID="txtQtyReceived" runat="server" /></td>
<td><asp:Label ID="lblRemaining" runat="server" Text='<%# Eval("Remaining") %>' /></td>
<td><%# Eval("Quantity") %></td>
<td>
<asp:LinkButton ID="lnkUpdate" runat="server"
class="glyphicon glyphicon-ok" CommandName="Update" />
<asp:LinkButton ID="lnkCancel" runat="server"
class="glyphicon glyphicon-remove" CommandName="Cancel" />
</td>
</tr>
</asp:Panel>
</EditItemTemplate>
</asp:ListView>
</tbody>
</table>
c# code
protected void lvSODetails_ItemEditing(object sender, ListViewEditEventArgs e)
{
lvSODetails.EditIndex = e.NewEditIndex;
GetInfo();
GetDetails();
}
protected void lvSODetails_ItemCanceling(object sender, ListViewCancelEventArgs e)
{
lvSODetails.EditIndex = -1;
GetInfo();
GetDetails();
}
protected void lvSODetails_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
string ProdID = (lvSODetails.Items[e.ItemIndex].FindControl("lblID") as Label).Text;
string Received = (lvSODetails.Items[e.ItemIndex].FindControl("txtQtyReceived") as TextBox).Text;
string Remaining = (lvSODetails.Items[e.ItemIndex].FindControl("lblRemaining") as Label).Text;
if (int.Parse(Received) < 0) // <~ this is where the code stops (error"input string was not in a correct format")
{
error.Visible = true;
lblError.Text = "Items received must not be lower than zero";
}
else if (int.Parse(Received) >= 0 && int.Parse(Received) <= int.Parse(Remaining))
{
SODetails = (DataTable)Session["sodelivery"];
foreach (DataRow row in SODetails.Rows)
{
if (row["ProductID"].ToString() == ProdID)
{
row["Received"] = Received;
break;
}
}
}
lvSODetails.EditIndex = -1;
GetInfo();
GetDetails();
}
~~~~ Edit ~~~~
listview databinding code
void GetDetails()
{
if (SODetails == null)
{
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "SELECT sod.ProductID, p.ProductName, sod.SOQtyReceived AS Received, " +
"(sod.SOQtyOrdered - sod.SOQtyReceived) AS Remaining, sod.SOQtyOrdered AS Quantity FROM SODetails AS sod " +
"INNER JOIN Products AS p ON sod.ProductID=p.ProductID WHERE sod.SONo=#SONo";
cmd.Parameters.Add("#SONo", SqlDbType.Int).Value = Request.QueryString["ID"].ToString();
SqlDataAdapter data = new SqlDataAdapter(cmd);
SODetails = new DataTable();
data.Fill(SODetails);
DataRow[] rowList = SODetails.Select();
foreach (DataRow dr in rowList)
{
dr["Received"] = "0";
}
lvSODetails.DataSource = SODetails;
lvSODetails.DataBind();
con.Close();
Session["sodelivery"] = SODetails;
}
else
{
lvSODetails.DataSource = SODetails;
lvSODetails.DataBind();
Session["sodelivery"] = SODetails;
}
}
Your problem isn't that you can't access the TextBox.
Use int.TryParse instead of int.Parse since you are reading user input.
int received;
if (!int.TryParse(Received, out received) || received < 0)
{
error.Visible = true;
lblError.Text = "Items received must not be lower than zero";
}

image redirect to another form in aspx?

This is my aspx code...
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
Width="88%" Height="100px">
<ItemTemplate>
<table width="0" border="0" cellpadding="0" cellspacing="1">
<tr>
<td>
<%#Eval("Coupon_Image")%>'
</td>
</tr>
<tr>
<td height="20px">
</td>
</tr>
<tr>
<td align="center">
<%--<asp:LinkButton ID="Button1" runat="server" Width="145" Height="34" border="0" CommandArgument='<%# Eval("Coupon_Id") %>'
CommandName="Get Coupoun" OnClick="getCoupon_Click"></asp:LinkButton>--%>
<asp:Button ID="getCoupon" runat="server" Width="145" Height="34" border="0" CommandArgument='<%# Eval("Coupon_Id")%>' Text="Get Coupon"
OnClick="getCoupon_Click" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
my code in code behind:
private void Binddata()
{
DataTable dtReport = new DataTable();
DataColumn Coupon_Id = new DataColumn("Coupon_Id");
DataColumn Coupon_Image = new DataColumn("Coupon_Image");
dtReport.Columns.Add(Coupon_Id);
dtReport.Columns.Add(Coupon_Image);
string sendquery = "select Coupon_Id,Coupon_Image from Admin where Coupon_Status='Active'";
SqlDataAdapter da = new SqlDataAdapter(sendquery, connection);
DataSet dsProfile = new DataSet();
da.Fill(dsProfile);
for (int i = 0; i < dsProfile.Tables[0].Rows.Count; i++)
{
DataRow row = dtReport.NewRow();
row["Coupon_Id"] = dsProfile.Tables[0].Rows[i]["Coupon_Id"].ToString();
string id = dsProfile.Tables[0].Rows[i]["Coupon_Id"].ToString();
string ImgName = dsProfile.Tables[0].Rows[i]["Coupon_Image"].ToString();
string Path = "http://localhost:2872/arpita-coupons/Coupon_Image/" + ImgName ;
row["Coupon_Image"] = "<img src='" + Path + "' height='200px' width='200px' />";
hddnpath.Value = Path + ImgName + id;
dtReport.Rows.Add(row);
}
DataList1.DataSource = dtReport;
DataList1.DataBind();
}
protected void getCoupon_Click(object sender, EventArgs e)
{
string id = hddnpath.Value;
string imagename = hddnpath.Value;
Response.Redirect("deals-forms.aspx?id="+id+" & ImgName="+imagename+" "+"");
}
my question is if i click the button to get the particular image to be redirect to the another page . but i am getting only the different image to the another aspx page...
You set id and imagename to the same value, then build a link from both. I guess there is the problem somewhere:
string id = hddnpath.Value;
string imagename = hddnpath.Value;
Response.Redirect("deals-forms.aspx?id=" + id // <-- this variable
+ " & ImgName=" + imagename // <-- and this one both
+ " " + ""); // contain hddnpath.Value

Categories