devlins
asked on
C# Dataset Custom Paging Errors????
How do I get this code to page data correctly?
Is there anything missing below???
There are two sets of navigation buttons, just for testing I was trying to see which set would work best.....
Please help!!!!!!!!!!!!
<%@ Page language="c#" Codebehind="Appl.aspx.cs" AutoEventWireup="false" Inherits="Appl.WebForm" Trace ="false" debug="true"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScri pt">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body bottomMargin="5" topMargin="5" MS_POSITIONING="GridLayout ">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 16px; WIDTH: 936px; POSITION: absolute; TOP: 8px; HEIGHT: 310px"
borderColor="#deba84" cellSpacing="1" borderColorDark="#deba84" cellPadding="1" width="936"
border="1">
<TR>
<TD style="WIDTH: 745px; HEIGHT: 69px" align="center" bgColor="#4a3c8c" colSpan="4"
rowSpan="1"><STRONG><FONT style="BACKGROUND-COLOR: transparent" color="#ffffff" size="4">   ; &nb sp; & nbsp;  ; &nb sp;
Multiple Order Waveplate Inventory</FONT></STRONG>< /TD>
</TR>
<TR>
<TD style="WIDTH: 146px; HEIGHT: 43px">
<P>Nominal Retardance
<asp:textbox id="DR" runat="server" Width="80px">0</asp:textbo x></P>
</TD>
<TD style="WIDTH: 195px; HEIGHT: 43px">
<P>Retardance Tolerance
<asp:textbox id="DRST" runat="server" Width="73px">0</asp:textbo x></P>
</TD>
<TD style="WIDTH: 183px; HEIGHT: 43px">
<P> Diameter
<asp:textbox id="Diameter" runat="server" Width="64px">0</asp:textbo x></P>
<P>Wavelength
<asp:textbox id="DL" runat="server" Width="79px">0</asp:textbo x></P>
</TD>
<TD style="WIDTH: 123px; HEIGHT: 43px">
<P>Temperature
<asp:textbox id="DT" runat="server" Width="81px">0</asp:textbo x> </ P>
</TD>
</TR>
<TR>
<TD id="MMMMMMM" style="WIDTH: 146px; HEIGHT: 10px" vAlign="baseline" width="146" runat="server">   ;</TD>
<TD style="WIDTH: 195px; HEIGHT: 10px" vAlign="baseline" width="195" runat="server"> +/-<a sp:textbox id="MRST" runat="server" Width="168px">0</asp:textb ox></TD>
<td style="WIDTH: 183px; HEIGHT: 10px">
<asp:textbox id="MR" runat="server" Width="152px" Visible="False">0</asp:tex tbox></td>
</TD>
<TD id="TextBox1" style="WIDTH: 123px; HEIGHT: 10px" width="123" runat="server"> </TD>
</TR>
<TR>
<TD style="WIDTH: 146px; HEIGHT: 23px"><asp:textbox id="TI" runat="server" Visible="False">0</asp:tex tbox></TD>
<TD style="WIDTH: 195px; HEIGHT: 23px"><asp:textbox id="Eq1" runat="server" Width="88px" AutoPostBack="True">0</asp :textbox>< asp:textbo x id="Eq2" runat="server" Width="88px">0</asp:textbo x></TD>
<TD style="WIDTH: 183px; HEIGHT: 23px"></TD>
<TD style="WIDTH: 123px; HEIGHT: 23px">
</TD>
</TR>
<TR>
<TD style="WIDTH: 146px; HEIGHT: 28px">
<P> </P>
</TD>
<TD style="WIDTH: 195px; HEIGHT: 28px"><asp:button id="QueryMe" runat="server" Text="QueryMe!"></asp:butt on></TD>
<TD style="WIDTH: 183px; HEIGHT: 28px"> <asp:button id="BCal" runat="server" Width="96px" Text="Equate"></asp:button ></TD>
<TD style="WIDTH: 123px; HEIGHT: 28px" colSpan="1" rowSpan="1"></TD>
</TR>
<TR>
<TD background="#deba84" bgColor="#deba84" colSpan="6"><asp:textbox id="Wavelength" runat="server" Width="64px" Visible="False">0</asp:tex tbox><asp: textbox id="Ret1" runat="server" Width="80px" Visible="False">0</asp:tex tbox><asp: textbox id="Tol1" runat="server" Width="56px" Visible="False">0</asp:tex tbox><asp: textbox id="dd" runat="server" Width="55px" Visible="False">0</asp:tex tbox><asp: textbox id="sT" runat="server" Width="64px" Visible="False">0</asp:tex tbox><asp: textbox id="d0" runat="server" Width="62px" Visible="False">0</asp:tex tbox><asp: textbox id="ML" runat="server" Width="68px" Visible="False">.6328</asp :textbox>< asp:textbo x id="cte" runat="server" Width="72px" Visible="False">1.377E-5</ asp:textbo x><asp:tex tbox id="dd0" runat="server" Width="60px" Visible="False">0</asp:tex tbox><asp: textbox id="MT" runat="server" Width="83px" Visible="False">21</asp:te xtbox><asp :label id="L1" runat="server" Width="72px"></asp:label>< asp:textbo x id="snD" runat="server" Width="62px" Visible="False">0</asp:tex tbox><asp: textbox id="dy" runat="server" Width="72px" Visible="False">0</asp:tex tbox><asp: textbox id="TBox" runat="server" Width="72px" Visible="False">1000</asp: textbox><a sp:textbox id="snM" runat="server" Width="64px" Visible="False">0</asp:tex tbox><asp: button id="CalcSql" runat="server" Width="57px" Text="Calculate" Visible="False"></asp:butt on></TD>
</TR>
<tr>
<TD><asp:label id="LabelC" runat="server"></asp:label ></TD>
<TD>
<asp:Button id="frst" runat="server" Text="first"></asp:Button>
<asp:Button id="prev" runat="server" Text="previous"></asp:Butt on>
<asp:Button id="nxt" runat="server" Text="next"></asp:Button>
<asp:Button id="las" runat="server" Text="last"></asp:Button>< /TD>
<td><asp:linkbutton id="FIRST" runat="server" Text="FIRST" Enabled="true">FIRST</asp: linkbutton >
<asp:linkbutton id="PREVIOUS" runat="server" Text="PREVIOUS">PREVIOUS</ asp:linkbu tton>
<asp:linkbutton id="NEXT" runat="server">NEXT</asp:l inkbutton>
<asp:linkbutton id="LAST" runat="server" Text="LAST">LAST</asp:link button></t d>
</tr>
</TABLE>
<asp:datagrid id=DGrid style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 320px" runat="server" Width="882px" DataMember="DTable2" DataSource="<%# DataS2 %>" AllowCustomPaging="True" CellPadding="3" BackColor="#DEBA84" BorderWidth="1px" CellSpacing="2" BorderStyle="None" BorderColor="#DEBA84" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False " OnUpdateCommand="OnUpdate_ Click" OnCancelCommand="CancelIt" OnEditCommand="Edit_Click" Height="478px" PageSize="25" OnPageIndexChanged="DGrid_ PageIndexC hanged">
<SelectedItemStyle Font-Bold="True" ForeColor="Silver" BackColor="#738A9C"></Sele ctedItemSt yle>
<EditItemStyle Font-Bold="True" BackColor="Gray"></EditIte mStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></Alte rnatingIte mStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></Item Style>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></Head erStyle>
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></Foot erStyle>
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Reserve"></asp:E ditCommand Column>
<asp:BoundColumn DataField="Inventory_Statu s" SortExpression="Inventory_ Status" HeaderText="Inventory_Stat us"></asp: BoundColum n>
<asp:BoundColumn DataField="Part_Key" SortExpression="Part_Key" ReadOnly="True" HeaderText="Part_Key"></as p:BoundCol umn>
<asp:BoundColumn DataField="Inventory_Type" SortExpression="Inventory_ Type" ReadOnly="True" HeaderText="Inventory_Type "></asp:Bo undColumn>
<asp:BoundColumn DataField="Operator_Name" SortExpression="Operator_N ame" ReadOnly="True" HeaderText="Operator_Name" ></asp:Bou ndColumn>
<asp:BoundColumn DataField="Diameter" SortExpression="Diameter" ReadOnly="True" HeaderText="Diameter"></as p:BoundCol umn>
<asp:BoundColumn DataField="Retardation" SortExpression="Retardatio n" ReadOnly="True" HeaderText="Retardation">< /asp:Bound Column>
<asp:BoundColumn DataField="Physical_Locati on" SortExpression="Physical_L ocation" ReadOnly="True"
HeaderText="Physical_Locat ion"></asp :BoundColu mn>
<asp:BoundColumn DataField="Retardation_Dec " SortExpression="Part_Key" ReadOnly="True" HeaderText="Retardation_De c"></asp:B oundColumn >
</Columns>
<PagerStyle Visible="False" NextPageText="Nex" PrevPageText="Prev" HorizontalAlign="Right" ForeColor="#4A3C8C"
Position="TopAndBottom" BackColor="#E7E7FF"></Page rStyle>
</asp:datagrid></form>
</body>
</HTML>
++++++++++++++++++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ +
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls ;
using System.Web.Configuration;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Text;
using System.Xml;
using System.Configuration;
//using System.Reflection;
namespace Appl
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm : System.Web.UI.Page
{
protected System.Web.UI.WebControls. Button B1;
protected System.Web.UI.WebControls. TextBox Ret2;
protected System.Web.UI.WebControls. TextBox Tol;
protected System.Web.UI.WebControls. Button B2;
protected System.Web.UI.WebControls. TextBox Diamet;
protected System.Web.UI.WebControls. Button QueryM;
protected System.Web.UI.HtmlControls .HtmlTable Cell TD1;
protected System.Data.SqlClient.SqlC ommand sqlCommand1;
protected System.Web.UI.WebControls. TextBox TextBox4;
protected System.Data.SqlClient.SqlC ommand sqlC;
protected System.Data.SqlClient.SqlC onnection Conn;
protected System.Data.DataRow DRow;
protected System.Data.DataColumn Dcol;
protected System.Collections.ArrayLi st ArL;
protected System.Data.SqlClient.SqlC onnection sqlConnection2;
protected System.Data.SqlClient.SqlC ommand sqlCo;
protected System.Data.SqlClient.SqlC ommand sqlC2;
protected System.Web.UI.WebControls. TextBox Retardation;
protected System.Data.DataSet Ds;
protected System.Web.UI.WebControls. Button QueryMe;
protected System.Web.UI.WebControls. DataGrid DGrid;
protected System.Data.DataTable DTabl;
protected System.Data.DataSet Dset;
protected System.Data.SqlClient.SqlC ommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlD ataAdapter DataA;
protected System.Web.UI.WebControls. Button BCal;
protected System.Web.UI.HtmlControls .HtmlTable Cell MMMMMMM;
protected System.Web.UI.WebControls. TextBox MR;
protected System.Web.UI.WebControls. TextBox MRST;
protected System.Web.UI.WebControls. CheckBox ck;
protected System.Data.SqlClient.SqlC ommand sqlCommand2;
protected System.Web.UI.WebControls. Label L;
protected System.Web.UI.WebControls. TemplateCo lumn CheckBoxColumn;
protected ArrayList bookidlist = new ArrayList();
protected System.Web.UI.WebControls. TextBox DRST;
protected System.Web.UI.WebControls. TextBox Eq1;
protected System.Web.UI.WebControls. TextBox Eq2;
protected System.Web.UI.WebControls. TextBox Diameter;
protected System.Web.UI.HtmlControls .HtmlTable Cell TextBox1;
protected System.Web.UI.WebControls. TextBox DT;
protected System.Web.UI.WebControls. TextBox DL;
protected System.Web.UI.WebControls. Button CalcSql;
protected System.Web.UI.WebControls. TextBox TBox;
protected System.Web.UI.WebControls. TextBox dy;
protected System.Web.UI.WebControls. TextBox snD;
protected System.Web.UI.WebControls. Label L1;
protected System.Web.UI.WebControls. TextBox MT;
protected System.Web.UI.WebControls. TextBox dd0;
protected System.Web.UI.WebControls. TextBox cte;
protected System.Web.UI.WebControls. TextBox ML;
protected System.Web.UI.WebControls. TextBox d0;
protected System.Web.UI.WebControls. TextBox dd;
protected System.Web.UI.WebControls. TextBox Tol1;
protected System.Web.UI.WebControls. TextBox Wavelength;
protected System.Web.UI.WebControls. TextBox sT;
protected System.Web.UI.WebControls. TextBox Ret1;
protected System.Web.UI.WebControls. TextBox snM;
protected System.Web.UI.WebControls. TextBox DR;
protected System.Web.UI.WebControls. TextBox TI;
protected Appl.DSet2 DSet2;
protected System.Data.DataTable DTable;
protected System.Data.DataSet DataS2;
protected System.Data.DataTable DTable2;
protected System.Web.UI.WebControls. LinkButton PREVIOUS;
protected System.Web.UI.WebControls. LinkButton FIRST;
protected System.Web.UI.WebControls. LinkButton LAST;
//protected System.Web.UI.WebControls. LinkButton FIRST;
//protected System.Web.UI.WebControls. Button NEXT;
//protected System.Web.UI.WebControls. LinkButton LAST;
public int CurrentPage;
//protected Prototype_2.Dset Dset;
/*static DataGrid DGrid2 = new DataGrid();
static int PageSize = 30;
static int TPages = 0;
static int CPage = 0;
static DataTable Waveplate;*/
static int pageSize = 30;
static int TPages = 0;
static int CPage = 0;
static string fvPart = "";
static string lvPart = "";
static string LastRecord ="";
protected System.Web.UI.WebControls. Label LabelC;
protected System.Web.UI.WebControls. Button frst;
protected System.Web.UI.WebControls. Button las;
protected System.Web.UI.WebControls. Button prev;
protected System.Web.UI.WebControls. LinkButton NEXT;
protected System.Web.UI.WebControls. Button nxt;
//static SqlConnection SqlCon = new SqlConnection("DataSource= VLOC-TRN-S QL; Integrated Security=SSPI;Initial Catalog=Waveplate");
//static SQLDataAdapter DataA= new SqlDataAdapter("",Waveplat e);
//static SQLCommand sqlCo = DataA.SelectCommand;
//protected Prototype_2.Dset Dset;
//protected System.Configuration.Confi gurationSe ttings.App Settings appSettings;
//protected System.Configuration.Confi gurationSe ttings.Get Config appSettings;
protected System.Data.DataTable DTab;
private void Page_Load(object sender, System.EventArgs e)
{
DGrid.PageIndexChanged += new DataGridPageChangedEventHa ndler(this .DGrid_Pag eIndexChan ged);
FIRST.Click += new System.EventHandler(this.f irst_Click );
NEXT.Click += new System.EventHandler(this.N ext_OnClic k);
PREVIOUS.Click += new System.EventHandler(this.p rev_Click) ;
LAST.Click += new System.EventHandler(this.l ast_Click) ;
frst.Click += new System.EventHandler(this.N avigationB uttonClick );
prev.Click += new System.EventHandler(this.N avigationB uttonClick );
nxt.Click += new System.EventHandler(this.N avigationB uttonClick );
las.Click += new System.EventHandler(this.N avigationB uttonClick );
if(!IsPostBack)
{
CurrentPage = 0;
//DGrid_PageIndexChanged += new DataGridPageChangedEventHa ndler(this .PageIndex Changed);
//DGrid.DataBind();
}
}
//#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>
///
protected void InitializeComponent()
{
System.Configuration.AppSe ttingsRead er configurationAppSettings = new System.Configuration.AppSe ttingsRead er();
this.Conn = new System.Data.SqlClient.SqlC onnection( );
this.sqlCo = new System.Data.SqlClient.SqlC ommand();
this.DTable = new System.Data.DataTable();
this.DataA = new System.Data.SqlClient.SqlD ataAdapter ();
this.DataS2 = new System.Data.DataSet();
this.DTable2 = new System.Data.DataTable();
this.DSet2 = new Appl.DSet2();
((System.ComponentModel.IS upportInit ialize)(th is.DTable) ).BeginIni t();
((System.ComponentModel.IS upportInit ialize)(th is.DataS2) ).BeginIni t();
((System.ComponentModel.IS upportInit ialize)(th is.DTable2 )).BeginIn it();
((System.ComponentModel.IS upportInit ialize)(th is.DSet2)) .BeginInit ();
this.QueryMe.DataBinding += new System.EventHandler(this.Q ueryMe_Cli ck);
this.QueryMe.Click += new System.EventHandler(this.Q ueryMe_Cli ck);
this.BCal.Click += new System.EventHandler(this.B Cal_Click) ;
this.DGrid.PageIndexChange d += new System.Web.UI.WebControls. DataGridPa geChangedE ventHandle r(this.DGr id_PageInd exChanged) ;
this.DGrid.SelectedIndexCh anged += new System.EventHandler(this.b tnUpdate_C lick);
//
// Conn
//
this.Conn.ConnectionString = ((string)(configurationApp Settings.G etValue("C onn.Connec tionString ", typeof(string))));
//
// sqlCo
//
this.sqlCo.CommandText = ((string)(configurationApp Settings.G etValue("s qlCo.Comma ndText", typeof(string))));
this.sqlCo.CommandTimeout = ((int)(configurationAppSet tings.GetV alue("sqlC o.CommandT imeout", typeof(int))));
this.sqlCo.Connection = this.Conn;
//
// DTable
//
this.DTable.Namespace = ((string)(configurationApp Settings.G etValue("D Table.Name space", typeof(string))));
this.DTable.TableName = ((string)(configurationApp Settings.G etValue("D Table.Tabl eName", typeof(string))));
//
// DataA
//
this.DataA.AcceptChangesDu ringFill = ((bool)(configurationAppSe ttings.Get Value("Dat aA.AcceptC hangesDuri ngFill", typeof(bool))));
this.DataA.ContinueUpdateO nError = true;
this.DataA.TableMappings.A ddRange(ne w System.Data.Common.DataTab leMapping[ ] {
new System.Data.Common.DataTab leMapping( "Table", "Waveplate", new System.Data.Common.DataCol umnMapping [] {
new System.Data.Common.DataCol umnMapping ("Part_Key ", "Part_Key"),
new System.Data.Common.DataCol umnMapping ("Physical _Location" , "Physical_Location"),
new System.Data.Common.DataCol umnMapping ("Retardat ion", "Retardation"),
new System.Data.Common.DataCol umnMapping ("Diameter ", "Diameter"),
new System.Data.Common.DataCol umnMapping ("Retardat ion_Dec", "Retardation_Dec")})});
//
// DataS2
//
this.DataS2.DataSetName = ((string)(configurationApp Settings.G etValue("D ataS2.Data SetName", typeof(string))));
this.DataS2.Locale = new System.Globalization.Cultu reInfo("en -US");
this.DataS2.Namespace = ((string)(configurationApp Settings.G etValue("D ataS2.Name space", typeof(string))));
this.DataS2.Tables.AddRang e(new System.Data.DataTable[] {
this.DTable2});
//
// DTable2
//
this.DTable2.Namespace = ((string)(configurationApp Settings.G etValue("D Table2.Nam espace", typeof(string))));
this.DTable2.TableName = ((string)(configurationApp Settings.G etValue("D Table2.Tab leName", typeof(string))));
//
// DSet2
//
this.DSet2.DataSetName = "DSet2";
this.DSet2.Locale = new System.Globalization.Cultu reInfo("en -US");
this.Load += new System.EventHandler(this.P age_Load);
this.PreRender += new System.EventHandler(this.P age_Load);
((System.ComponentModel.IS upportInit ialize)(th is.DTable) ).EndInit( );
((System.ComponentModel.IS upportInit ialize)(th is.DataS2) ).EndInit( );
((System.ComponentModel.IS upportInit ialize)(th is.DTable2 )).EndInit ();
((System.ComponentModel.IS upportInit ialize)(th is.DSet2)) .EndInit() ;
}
public void Calc_Click(Object Sender, EventArgs e)
{
Eq1.Text = (double.Parse(TI.Text) + double.Parse(DRST.Text)).T oString();
Eq2.Text = (double.Parse(TI.Text) - double.Parse(DRST.Text)).T oString();
}
public void Add_Click (object sender, EventArgs e)
{
Eq1.Text = (double.Parse(Ret1.Text) + double.Parse(Tol1.Text)).T oString();
}
public void Add_Subtract (object sender, EventArgs e)
{
Eq2.Text = (double.Parse(Ret2.Text) - double.Parse(Tol1.Text)).T oString();
}
public void interger (object sender, EventArgs el)
{
int DefFrom = -1000000;
int DefTo = 100000000;
try
{
int F;
int T;
F = Eq1.Text.Trim().Length==0? DefFrom:in t.Parse(Eq 1.Text);
T = Eq2.Text.Trim().Length==0? DefTo:int. Parse(Eq2. Text);
//string sql = "select * from Waveplate";
//sql += "where Retardation >" +From.ToString();
//sql += "and field2 <" +to.ToString();
}
catch (System.Exception e)
{
Response.Write(e.Message);
}
}
protected void QueryMe_Click(object sender, EventArgs e)
{
int CIndex = 0;
int pageSize = 10;
Conn.Open();
//string LRecord = DSet2.Tables["Waveplate"]. Rows[PageS ize -1]["Part_Key"].ToString() ;
string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')order by Physical_Location";
//"(Select * from Waveplate where (Retardation between " + Eq2.Text + " and " + Eq1.Text + ")) and Diameter = '" + Diameter.Text + "') or ((Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')order by Physical_Location";
//string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')";
//string sqlC = String.Format("(select * from Waveplate where Retardation between {0} and {1} and {2} = Diameter)", Eq1.Text, Eq2.Text , Diameter.Text) ;
DataA = new System.Data.SqlClient.SqlD ataAdapter (sqlC, Conn);
//SqlCommand CommandText = Conn.CreateCommand();
//sqlC.Connection = Conn;
//string Q = "select * from Main_Wave_Inv (Retardation,Retardation)( @Ret1,@Ret 2)";
//SqlCommand sqlCom = new SqlCommand(sqlC, Conn);
//string SQ = System.Configuration.Confi gurationSe ttings.App Settings(" Conn");
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C onn) ;
CIndex += pageSize;
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To String()] = DGrid.Items[0].Cells[0].Te xt;
DataA.Fill(DataS2, CIndex, CurrentPage, "Waveplate");
DGrid.DataSource = DataS2;
DGrid.DataMember = "Waveplate";
DataView MiDView = DataS2.Tables["Waveplate"] .DefaultVi ew;
int Rcount = MiDView.Table.Rows.Count;
LabelC.Text = Rcount.ToString();
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To String()] = DGrid.Items[0].Cells[0].Te xt;
//DGrid.CurrentPageIndex = DGrid.Page;
//DataS["Timestamp"] = DateTime.Now.Date.ToLocalT ime();
//DTable.Clear();
//DTable.Columns.Clear();
int RCount = DataS2.Tables["Waveplate"] .Rows.Coun t;
//LabelC.Text = RCount.ToString();
DataS2.Tables.Add();
DGrid.DataBind();
//Session["Waveplate"]= DataS2;
string LastRecord = DataS2.Tables["Waveplate"] .Rows[Rcou nt -1]["Physical_Location"].T oString();
DGrid.VirtualItemCount.ToS tring();
//ViewState["LastKey"] = DGrid.DataKeys[DGrid.Items .Count];
//ViewState["FirstKey"] = DGrid.DataKeys[-1];
//int Physical_Location = Convert.ToInt32(ViewState[ "FirstKey" ]);
//int Physical_Location = Convert.ToInt32(ViewState[ "LastKey"] );
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla te");
/*if (DGrid.Items.Count < DGrid.PageSize)
{
NEXT.Enabled = false;
}
else
{
LAST.Enabled = false;
}*/
Conn.Close();
}
//this.Dcol.DataType = MiSqlDReader.GetFieldType( i);
//this.Dcol.ColumnName = MiSqlDReader.GetName(i);
//this.Dset.Tables(Main_Wa veplate_In v).Columns .Add();
//}
//public System.Data.DataTable GetTable(System.Data.SqlCl ient.SqlDa taReader Reader)
//{
//}
//catch(System.Exception ex)
//{
// Response.Write(ex.Message) ;
//........Messagebox.Show( ex.Message );
//#endregion
//RcdCount = DS.Tables("pubs").Rows.Cou nt.ToStrin g()
//totalCount=ds.Tables["Pe ople"].Row s.Count.To String();
private void BCal_Click(object sender, EventArgs e)
{
try
{
//snD.Text = (double.Parse(.0088641 + .000107057) * (DL.Text)^2+1.9893*(.00000 1/(DL.Text )^4)-(.000 17175)*(DL .Text)^2-D T.Text*(.0 00001)*(1+ DT.Text/90 0)*1.01+0. 2*(DL.Text )*2;
double dr = Double.Parse(DR.Text);
double dl = Double.Parse(DL.Text);
double dt = Double.Parse(DT.Text);
double sn = Double.Parse(snD.Text);
double d = Double.Parse(d0.Text);
double s = Double.Parse(sT.Text);
double m = Double.Parse(MT.Text);
double dx = Double.Parse(dy.Text);
double ct = Double.Parse(cte.Text);
double sn2 = Double.Parse(snM.Text);
double m1 = Double.Parse(ML.Text);
double m2 = Double.Parse(MR.Text);
double d1 = Double.Parse(dd0.Text);
double drs = Double.Parse(DRST.Text);
double d2 = Double.Parse(dd.Text);
double mrt = Double.Parse(MRST.Text);
//snD.Text = double.Parse(snD.Text).ToS tring();
//int z;
//z = 1000;
//TBox.Text = z.ToString();
//m1/z
//DL.Text = (double.Parse(Wavelength.T ext) / double.Parse(TBox.Text)).T oString();
//sn = (.0088641 + 1.07057 * (.0001)/(dl * dl) + (1.9893 *.000001)/(dl*4*4) - .00017175*(dl*dl)-(dt) * .000001*1+dt/900*(1.01+0.2 )*(dl*dl)) ;
//sn = (Double.Parse("8.8641E-03" )+1.07057* (Double.Pa rse("1E-04 ")/(dl * dl)) + 1.9893*Math.Pow(Double.Par se("1E-06" )/dl, 4) - Double.Parse("1.7175E-04") *dl*dl-dt* (Double.Pa rse("1E-06 ")*(1+dt/9 00)*(1.01+ 0.2*dl*dl) ));
sn =8.8641*10e-4+1.07057*(10e -5/(Math.P ow(dl,2))) +1.9893*(1 0e-7/(Math .Pow(dl,4) ))-1.7175* 10e-5*(Mat h.Pow(dl,2 ))-dt*10e- 7*(1+dt/90 0)*(1.01+0 .2*(Math.P ow(dl,2))) ;
d = (dr*dl)/sn;
//s = (dt-m);
s = (m-dt);
dx = d*(1+ct*s);
//sn2 = (Double.Parse("8.8641E-03" ) + 1.07057*(Double.Parse("1E- 04")/(m1 * m1)) + 1.9893*Math.Pow(Double.Par se("1E-06" )/m1, 4)- Double.Parse("1.7175E-04") *m1*m1-m * (Double.Parse("1E-06")*(1+ m/900)*(1. 01+0.2*m1* m1)));
sn2 = 8.8641*10e-4+1.07057*(10e- 5/(Math.Po w(m1,2)))+ 1.9893*(10 e-7/(Math. Pow(m1,4)) )-1.7175*1 0e-5*(Math .Pow(m1,2) )-m*10e-7* (1+m/900)* (1.01+0.2* (Math.Pow( m1,2)));
m2 = (sn2*dx)/m1;
d1 = (drs*dl)/sn;
d2 = d1*(1+ct*s);
mrt = (sn2*d2)/m1;
//snD.Text = snD.Text.ToString();
//sT.Text = (double.Parse(MT.Text) - double.Parse(DT.Text)).ToS tring();
snD.Text = sn.ToString();
d0.Text =d.ToString();
dd.Text = d2.ToString();
DRST.Text = drs.ToString();
snM.Text = sn2.ToString();
MRST.Text = mrt.ToString();
dy.Text = dx.ToString();
sT.Text = s.ToString();
MR.Text = m2.ToString();
dd0.Text = d1.ToString();
//int DefFrom = -1000000;
Eq1.Text = (double.Parse(TI.Text) + double.Parse(DRST.Text)).T oString();
Eq2.Text = (double.Parse(TI.Text) - double.Parse(DRST.Text)).T oString();
TI.Text=MR.Text;
}
catch (FormatException ex)
{
//ex.Message = "FormatException" + ex;
//MessageBox.Show("Message " + ex);\
Response.Write("Error Message is" + ex.ToString());
Response.Write(ex.Message) ;
}
}
private void Conn_InfoMessage(object sender, System.Data.SqlClient.SqlI nfoMessage EventArgs e)
{
}
private void Eq1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
//Checkbox update function
//OleDbCommand c = new OleDbCommand("UPDATE Item SET Status='Loan'", con);
//con.Open();
//c.ExecuteNonQuery();
/* string key = DGrid.DataKeys[e.Item.Item Index].ToS tring();
string Sq;
Sq = "Update [Waveplate]" +
"set Reserve_User =?, Reserve_User =?," +
"Inventory_Status=?, Inventory_Status=R"+
"where Part_Key =?, and Physical_Location=?";
SqlCommand SCom = new SqlCommand(Sq, Conn);
SqlParameterCollection CSql = SCom.Parameters;
CSql.Add("Inventory_Status ", SqlDbType.Char);
CSql.Add ("Reserve_Time", SqlDbType.DateTime);
DataA.Update(DataS, "Waveplate");
DataS.AcceptChanges();*/
}
public void Edit_Click(Object source, System.Web.UI.WebControls. DataGridCo mmandEvent Args e)
{
DGrid.EditItemIndex = e.Item.ItemIndex;
BindIt();
}
/* public void DGrid_ItemDataBound(object sender,
System.Web.UI.WebControls. DataGridIt emEventArg s e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
DataRowView drv = (DataRowView) e.Item.DataItem;
String currentgenre = drv["Inventory_Status"].To String();
DropDownList ddl =
(DropDownList) e.Item.FindControl("DropDo wnList1");
ddl.SelectedIndex =
ddl.Items.IndexOf(ddl.Item s.FindByTe xt(current genre));
}
}
*/
protected void OnUpdate_Click(Object source, System.Web.UI.WebControls. DataGridCo mmandEvent Args e)
{
DateTime DT = DateTime.Now;
string ToDa = DT.ToString("mm/dd/yyyy hh:nn:ss");
string Inv;
//bool Discon=((CheckBox)e.Item.F indControl ("Part_Key ")).Checke d;
string Key = DGrid.DataKeys[e.Item.Item Index].ToS tring();
TextBox box;
//DropDownList = box;
box = (TextBox)(e.Item.Cells[1]. Controls[0 ]);
Inv=box.Text;
//Label L;
//ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Item s.FindByTe xt(Inv));
// Gets the value the TextBox control in the 7th column
//Convert.ToDateTime((e.It em.Cells[8 ].Controls [0]));
//Convert.ToDateTime(e.Ite m.Cells(8) .Text);
//L.Text = ToDa;
ToDa = ToDa.ToString();
string Sq;
Sq = "Update Waveplate set Inventory_Status=@Inventor y_Status where Part_Key = @Part_Key";
//Reserve_Timestamp = "+"'GetDate()'"+
//Sq = "Update [Waveplate]" + "set Inventory_Status=@Inventor y_Status"+
//"where Part_Key =@Part_Key";
SqlCommand SCom = new SqlCommand(Sq, Conn);
//SqlParameterCollection CSql = SCom.Parameters;
SCom.Parameters.Add("@Part _Key", SqlDbType.Char);
SCom.Parameters["@Part_Key "].Value=K ey;
SCom.Parameters.Add("@Inve ntory_Stat us", SqlDbType.Char);
SCom.Parameters["@Inventor y_Status"] .Value=Inv ;
//SCom.Parameters.Add("@Re serve_Time ", SqlDbType.DateTime);
//SCom.Parameters["@Reserv e_Time"].V alue=ToDa;
SCom.Parameters["@Part_Key "].Value = DGrid.DataKeys[(int)e.Item .ItemIndex ];
SCom.Connection.Open();
try
{
SCom.ExecuteNonQuery();
Response.Write ("<b></b><br>" + Sq);
DGrid.EditItemIndex = -1;
}
catch (SqlException E)
{
if (E.Number == 2627)
Response.Write("ERROR: ");
else
Response.Write ("ERROR: ");
}
SCom.Connection.Close();
BindIt();
}
//DataA.Update(DataS, "Waveplate");
//DataS.AcceptChanges();
public void DGrid_PageIndexChanged(obj ect source, DataGridPageChangedEventAr gs e)
{
DGrid.CurrentPageIndex = e.NewPageIndex;
DataBind();
}
public void CancelIt(Object sender, DataGridCommandEventArgs e)
{
DGrid.EditItemIndex = -1;
BindIt();
}
protected void DGrid_Checked(object sender, System.EventArgs e)
{
/* //CType(y.Item.ItemType = )
int Rcount = 0;
StringBuilder DGridMe = new StringBuilder();
//int Part_Key =(int)DGrid.DataKeys[(int) e.ItemInde x];
//bool Reserved=((CheckBox)e.Item .FindContr ol("Reserv ed")).Chec ked;
//CheckBox CBox = (ck) e.Item.FindControl("Invent ory_Status ");
//Binding CheckBind = new Binding("Check", DSet,"Waveplate.Inventory_ Status");
//ck.DataBindingsAdd(Check Bind);
//findout the selected item index and bindgrid again
//DGrid.EditItemIndex = (int)y.Item.ItemIndex;
//CheckBox checkbx;
foreach (DataGridItem DGridItem in DGrid.Items)
{
CheckBox Ccheck = (CheckBox)DGridItem.Cells[ 0].Control s[2];
//DataRow ro;
//TextBox t;
t = (TextBox)DGridItem.Cells[2 ].Controls [0];
//ck(e.Item.Cells[6].Contr ols[2]);
//DataGridItem DGI = DGrid.Items[i].FindControl ("Inventor y_Status") ;
//ck = (y.Item.FindControl());
//CBox.Checked
//bool CValu;
//string K = DGrid.DataKeys[y.Item.Item Index].ToS tring();
if(Ccheck.Checked == true)
{
Rcount++;
Ccheck.Text = "Reserv";
DGridMe.AppendFormat("Chec kBoxes {0} were checked <br>", DGrid.DataKeys[DGridItem.I temIndex]. ToString() );
DGridMe.AppendFormat("Tota l number selected is: {0}", Rcount.ToString());
}
}
//DGridMe.AppendFormat("To tal number selected is: {0}", Rcount.ToString());
DGridMe.Append("<hr>");
L1.Text = DGridMe.ToString();
//DGridMe.AppendFormat("Ch eckBoxes {0} were checked <br>", DGrid.DataKeys[DGridItem.I temIndex]. ToString() );
}
private void dd_TextChanged(object sender, System.EventArgs y)
{
//UpdateCommand.Parameters .Add("@ck" , SqlDbType.VarChar, 99).Value = ck.Checked.ToString
/*<asp:TemplateColumn HeaderText="Reservation">
<ItemTemplate><asp:Checkbo x ID =ck Runat="server" Text=<%#DataBinder.Eval(Co ntainer.Da taItem,"In ventory_St atus")%>
Checked ='<%#DataBinder.Eval(Conta iner.DataI tem,"Y")%> '></asp:Ch eckbox></a sp:Checkbo x></ItemTe mplate></a sp:Templat eColumn>*/
//if ck.Checked = DGrid.EditItemIndex = -1;
//DataBind();
}
public void btnUpdate_Click(object sender, System.EventArgs e)
{
int i;
DataGridItem dgi;
int bookid;
TextBox TextBoxTitle;
CheckBox ChInv;
TextBox TextBoxPrice;
string Sq2;
Sq2 = "Update Waveplate set Inventory_Status=@Inventor y_Status where Part_Key =@Part_Key";
SqlCommand SCom2 = new SqlCommand(Sq2, Conn);
for(i = 0; i <= DGrid.Items.Count -1 ; i++)
{
dgi = DGrid.Items[i];
Label LabelBookId = (Label) dgi.Cells[0].Controls[1];
bookid = int.Parse(LabelBookId.Text );
TextBoxTitle = (TextBox) dgi.FindControl("TextBoxTi tle");
ChInv = (CheckBox) dgi.FindControl("CheckBoxI nStock");
TextBoxPrice = (TextBox) dgi.FindControl("TextBoxPr ice");
//this.dcmdUpdateBooks.Par ameters["@ bookid"].V alue = bookid;
//this.dcmdUpdateBooks.Par ameters["@ Title"].Va lue = TextBoxTitle.Text;
SCom2.Parameters["@Invento ry_Status" ].Value =
ChInv.Checked;
ChInv.Text = "R";
//this.dcmdUpdateBooks.Par ameters["@ Price"].Va lue =
float.Parse(TextBoxPrice.T ext);
this.Conn.Open();
SCom2.ExecuteNonQuery();
this.Conn.Close();
}
}
public void BindIt()
{
Conn.Open();
string sqlC = "(select Top 30 * from Waveplate where ((Retardation between " + Eq2.Text + " and " + Eq1.Text + ") or (Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')";
//string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')";
//string sqlC = String.Format("(select * from Waveplate where Retardation between {0} and {1} and {2} = Diameter)", Eq1.Text, Eq2.Text , Diameter.Text) ;
DataA = new System.Data.SqlClient.SqlD ataAdapter (sqlC, Conn);
//SqlCommand CommandText = Conn.CreateCommand();
//sqlC.Connection = Conn;
//string Q = "select * from Main_Wave_Inv (Retardation,Retardation)( @Ret1,@Ret 2)";
//SqlCommand sqlCom = new SqlCommand(sqlC, Conn);
//string SQ = System.Configuration.Confi gurationSe ttings.App Settings(" Conn");
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C onn) ;
DataA.Fill(DataS2, "Waveplate");
DGrid.DataSource = DataS2;
DGrid.DataMember = "Waveplate";
DTable.Clear();
DTable.Columns.Clear();
DataS2.Tables.Add();
DGrid.DataBind();
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla te");
Conn.Close();
}
/*private void btnUp_Click(object sender, System.EventArgs e)
{
int i;
DataGridItem dgi;
int bookid;
//Rest of declarations here
for(i = 0; i <= DGrid.Items.Count -1 ; i++)
{
dgi = DGrid.Items[i];
TableCell tc = dgi.Cells[0];
string s = dgi.Cells[0].Text;
Label LabelBookId = (Label) dgi.Cells[3].Controls[1];
bookid = int.Parse(LabelBookId.Text );
if (bookidlist.Contains(booki d))
{
// Update code here
}
}
}
protected void RowChanged( object sender, System.EventArgs e)
{
DataGridItem dgi = (DataGridItem)(((Control)s ender).Nam ingContain er);
Label bookidlabel = (Label) dgi.Cells[3].Controls[1];
int Part_Key = int.Parse(bookidlabel.Text );
if (!bookidlist.Contains(Part _Key))
{
bookidlist.Add(Part_Key);
}
}*/
public void ck_Click(object sender, System.EventArgs e)
{
//if (ck.Checked)
// Inventory_Status.
}
private void dy_TextChanged(object sender, System.EventArgs e)
{
}
/*public static void GetData(string direction)
{
sqlCo.Parameters.Clear();
switch(direction)
{
case "Next":
sqlCo.CommandText = "(Select * from Waveplate where ((Retardation between " + Eq2.Text + " and " + Eq1.Text + ") or (Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')";
sqlCo.Parameters.Add("@Par t_Key",Sql DBType.Cha r,15).Valu e = lvPart;
break;
case "Previous":
sqCo.CommandText = "(Select * from Waveplate where ((Retardation between " + Eq2.Text + " and " + Eq1.Text + ") or (Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')";
sqlCo.Parameters.Add("@Par t_Key",Sql DBType.Cha r,15).Valu e = fvPart;
break;
}
}*/
private void DR_TextChanged(object sender, System.EventArgs e)
{
}
public void prev_Click(object sender, System.EventArgs e)
{
if
(DGrid.CurrentPageIndex > 0)
{
DGrid.CurrentPageIndex -=1;
DataBind( );
}
}
public void last_Click(object sender, System.EventArgs e)
{
if (DGrid.CurrentPageIndex< DGrid.PageCount -1)
{
DGrid.CurrentPageIndex = DGrid.PageCount -1;
DataBind();
}
}
public void Next_OnClick(object sender, EventArgs e)
{
if (DGrid.CurrentPageIndex < DGrid.PageCount -1)
{
}
DGrid.CurrentPageIndex += 1;
sqlC.CommandText = "Select Top" +pageSize+" * from Waveplate"+
"where Physical_Location > @Physical_location Order By Physical_Location";
sqlC.Parameters.Add("@Phys ical_locat ion", SqlDbType.Int, 4).Value = LastRecord;
}
public void first_Click(object sender, EventArgs e)
{
if (DGrid.CurrentPageIndex <0)
{
DGrid.CurrentPageIndex = 0;
Bind();
}
}
private void NavigationButtonClick(obje ct sender, System.EventArgs e)
{
string direction = ((Button)sender).CommandNa me;
switch (direction.ToUpper())
{
case "frst" :
DGrid.CurrentPageIndex = 0;
break;
case "prev" :
DGrid.CurrentPageIndex =
Math.Max(DGrid.CurrentPage Index -1, 0);
break;
case "nxt" :
DGrid.CurrentPageIndex =
Math.Min(DGrid.CurrentPage Index + 1,
DGrid.PageCount - 1);
break;
case "las" :
DGrid.CurrentPageIndex = DGrid.PageCount - 1;
break;
default :
break;
}
}
protected void Bind()
{
int CIndex = 0;
int pageSize = 10;
Conn.Open();
//string LastRecord = DSet2.Tables["Waveplate"]. Rows[pageS ize -1]["Physical_Location"].T oString();
string sqlCo = "(SELECT * From Waveplate where Physical_Location > "+LastRecord+") order by Physical_Location";
//DataA.SelectCommand.Comm andText = sqlCo;
//DataS2.Tables["Waveplate "].Rows.Cl ear();
//sqlC2.Parameters.Add("@P hysical_lo cation", SqlDbType.Int, 4).Value = LastRecord;
//"(Select * from Waveplate where (Retardation between " + Eq2.Text + " and " + Eq1.Text + ")) and Diameter = '" + Diameter.Text + "') or ((Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')order by Physical_Location";
//string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')";
//string sqlC = String.Format("(select * from Waveplate where Retardation between {0} and {1} and {2} = Diameter)", Eq1.Text, Eq2.Text , Diameter.Text) ;
DataA = new System.Data.SqlClient.SqlD ataAdapter (sqlCo, Conn);
//SqlCommand CommandText = Conn.CreateCommand();
//sqlC.Connection = Conn;
//string Q = "select * from Main_Wave_Inv (Retardation,Retardation)( @Ret1,@Ret 2)";
//SqlCommand sqlCom = new SqlCommand(sqlC, Conn);
//string SQ = System.Configuration.Confi gurationSe ttings.App Settings(" Conn");
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C onn) ;
CIndex += pageSize;
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To String()] = DGrid.Items[0].Cells[0].Te xt;
DataA.Fill(DataS2, CIndex, pageSize, "Waveplate");
DGrid.DataSource = DataS2;
DGrid.DataMember = "Waveplate";
DataView MiDView = DataS2.Tables["Waveplate"] .DefaultVi ew;
int Rcount = MiDView.Table.Rows.Count;
LabelC.Text = Rcount.ToString();
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To String()] = DGrid.Items[0].Cells[0].Te xt;
//DGrid.CurrentPageIndex = DGrid.Page;
//DataS["Timestamp"] = DateTime.Now.Date.ToLocalT ime();
//DTable.Clear();
//DTable.Columns.Clear();
int RCount = DataS2.Tables["Waveplate"] .Rows.Coun t;
//LabelC.Text = RCount.ToString();
DataS2.Tables.Add();
DGrid.DataBind();
//Session["Waveplate"]= DataS2;
//string LastRecord = DataS2.Tables["Waveplate"] .Rows[Rcou nt -1]["Physical_Location"].T oString();
DGrid.VirtualItemCount.ToS tring();
//ViewState["LastKey"] = DGrid.DataKeys[DGrid.Items .Count];
//ViewState["FirstKey"] = DGrid.DataKeys[-1];
//int Physical_Location = Convert.ToInt32(ViewState[ "FirstKey" ]);
//int Physical_Location = Convert.ToInt32(ViewState[ "LastKey"] );
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla te");
/*if (DGrid.Items.Count < DGrid.PageSize)
{
NEXT.Enabled = false;
}
else
{
LAST.Enabled = false;
}*/
Conn.Close();
}
}
}
Is there anything missing below???
There are two sets of navigation buttons, just for testing I was trying to see which set would work best.....
Please help!!!!!!!!!!!!
<%@ Page language="c#" Codebehind="Appl.aspx.cs" AutoEventWireup="false" Inherits="Appl.WebForm" Trace ="false" debug="true"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScri
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body bottomMargin="5" topMargin="5" MS_POSITIONING="GridLayout
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 16px; WIDTH: 936px; POSITION: absolute; TOP: 8px; HEIGHT: 310px"
borderColor="#deba84" cellSpacing="1" borderColorDark="#deba84" cellPadding="1" width="936"
border="1">
<TR>
<TD style="WIDTH: 745px; HEIGHT: 69px" align="center" bgColor="#4a3c8c" colSpan="4"
rowSpan="1"><STRONG><FONT style="BACKGROUND-COLOR: transparent" color="#ffffff" size="4">  
Multiple Order Waveplate Inventory</FONT></STRONG><
</TR>
<TR>
<TD style="WIDTH: 146px; HEIGHT: 43px">
<P>Nominal Retardance
<asp:textbox id="DR" runat="server" Width="80px">0</asp:textbo
</TD>
<TD style="WIDTH: 195px; HEIGHT: 43px">
<P>Retardance Tolerance
<asp:textbox id="DRST" runat="server" Width="73px">0</asp:textbo
</TD>
<TD style="WIDTH: 183px; HEIGHT: 43px">
<P> Diameter
<asp:textbox id="Diameter" runat="server" Width="64px">0</asp:textbo
<P>Wavelength
<asp:textbox id="DL" runat="server" Width="79px">0</asp:textbo
</TD>
<TD style="WIDTH: 123px; HEIGHT: 43px">
<P>Temperature
<asp:textbox id="DT" runat="server" Width="81px">0</asp:textbo
</TD>
</TR>
<TR>
<TD id="MMMMMMM" style="WIDTH: 146px; HEIGHT: 10px" vAlign="baseline" width="146" runat="server">  
<TD style="WIDTH: 195px; HEIGHT: 10px" vAlign="baseline" width="195" runat="server"> +/-<a
<td style="WIDTH: 183px; HEIGHT: 10px">
<asp:textbox id="MR" runat="server" Width="152px" Visible="False">0</asp:tex
</TD>
<TD id="TextBox1" style="WIDTH: 123px; HEIGHT: 10px" width="123" runat="server"> </TD>
</TR>
<TR>
<TD style="WIDTH: 146px; HEIGHT: 23px"><asp:textbox id="TI" runat="server" Visible="False">0</asp:tex
<TD style="WIDTH: 195px; HEIGHT: 23px"><asp:textbox id="Eq1" runat="server" Width="88px" AutoPostBack="True">0</asp
<TD style="WIDTH: 183px; HEIGHT: 23px"></TD>
<TD style="WIDTH: 123px; HEIGHT: 23px">
</TD>
</TR>
<TR>
<TD style="WIDTH: 146px; HEIGHT: 28px">
<P> </P>
</TD>
<TD style="WIDTH: 195px; HEIGHT: 28px"><asp:button id="QueryMe" runat="server" Text="QueryMe!"></asp:butt
<TD style="WIDTH: 183px; HEIGHT: 28px"> <asp:button id="BCal" runat="server" Width="96px" Text="Equate"></asp:button
<TD style="WIDTH: 123px; HEIGHT: 28px" colSpan="1" rowSpan="1"></TD>
</TR>
<TR>
<TD background="#deba84" bgColor="#deba84" colSpan="6"><asp:textbox id="Wavelength" runat="server" Width="64px" Visible="False">0</asp:tex
</TR>
<tr>
<TD><asp:label id="LabelC" runat="server"></asp:label
<TD>
<asp:Button id="frst" runat="server" Text="first"></asp:Button>
<asp:Button id="prev" runat="server" Text="previous"></asp:Butt
<asp:Button id="nxt" runat="server" Text="next"></asp:Button>
<asp:Button id="las" runat="server" Text="last"></asp:Button><
<td><asp:linkbutton id="FIRST" runat="server" Text="FIRST" Enabled="true">FIRST</asp:
<asp:linkbutton id="PREVIOUS" runat="server" Text="PREVIOUS">PREVIOUS</
<asp:linkbutton id="NEXT" runat="server">NEXT</asp:l
<asp:linkbutton id="LAST" runat="server" Text="LAST">LAST</asp:link
</tr>
</TABLE>
<asp:datagrid id=DGrid style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 320px" runat="server" Width="882px" DataMember="DTable2" DataSource="<%# DataS2 %>" AllowCustomPaging="True" CellPadding="3" BackColor="#DEBA84" BorderWidth="1px" CellSpacing="2" BorderStyle="None" BorderColor="#DEBA84" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False
<SelectedItemStyle Font-Bold="True" ForeColor="Silver" BackColor="#738A9C"></Sele
<EditItemStyle Font-Bold="True" BackColor="Gray"></EditIte
<AlternatingItemStyle BackColor="#F7F7F7"></Alte
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></Item
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></Head
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></Foot
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Reserve"></asp:E
<asp:BoundColumn DataField="Inventory_Statu
<asp:BoundColumn DataField="Part_Key" SortExpression="Part_Key" ReadOnly="True" HeaderText="Part_Key"></as
<asp:BoundColumn DataField="Inventory_Type"
<asp:BoundColumn DataField="Operator_Name" SortExpression="Operator_N
<asp:BoundColumn DataField="Diameter" SortExpression="Diameter" ReadOnly="True" HeaderText="Diameter"></as
<asp:BoundColumn DataField="Retardation" SortExpression="Retardatio
<asp:BoundColumn DataField="Physical_Locati
HeaderText="Physical_Locat
<asp:BoundColumn DataField="Retardation_Dec
</Columns>
<PagerStyle Visible="False" NextPageText="Nex" PrevPageText="Prev" HorizontalAlign="Right" ForeColor="#4A3C8C"
Position="TopAndBottom" BackColor="#E7E7FF"></Page
</asp:datagrid></form>
</body>
</HTML>
++++++++++++++++++++++++++
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls
using System.Web.Configuration;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Text;
using System.Xml;
using System.Configuration;
//using System.Reflection;
namespace Appl
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls
protected System.Data.SqlClient.SqlC
protected System.Web.UI.WebControls.
protected System.Data.SqlClient.SqlC
protected System.Data.SqlClient.SqlC
protected System.Data.DataRow DRow;
protected System.Data.DataColumn Dcol;
protected System.Collections.ArrayLi
protected System.Data.SqlClient.SqlC
protected System.Data.SqlClient.SqlC
protected System.Data.SqlClient.SqlC
protected System.Web.UI.WebControls.
protected System.Data.DataSet Ds;
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Data.DataTable DTabl;
protected System.Data.DataSet Dset;
protected System.Data.SqlClient.SqlC
protected System.Data.SqlClient.SqlD
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Data.SqlClient.SqlC
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected ArrayList bookidlist = new ArrayList();
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected Appl.DSet2 DSet2;
protected System.Data.DataTable DTable;
protected System.Data.DataSet DataS2;
protected System.Data.DataTable DTable2;
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
//protected System.Web.UI.WebControls.
//protected System.Web.UI.WebControls.
//protected System.Web.UI.WebControls.
public int CurrentPage;
//protected Prototype_2.Dset Dset;
/*static DataGrid DGrid2 = new DataGrid();
static int PageSize = 30;
static int TPages = 0;
static int CPage = 0;
static DataTable Waveplate;*/
static int pageSize = 30;
static int TPages = 0;
static int CPage = 0;
static string fvPart = "";
static string lvPart = "";
static string LastRecord ="";
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
//static SqlConnection SqlCon = new SqlConnection("DataSource=
//static SQLDataAdapter DataA= new SqlDataAdapter("",Waveplat
//static SQLCommand sqlCo = DataA.SelectCommand;
//protected Prototype_2.Dset Dset;
//protected System.Configuration.Confi
//protected System.Configuration.Confi
protected System.Data.DataTable DTab;
private void Page_Load(object sender, System.EventArgs e)
{
DGrid.PageIndexChanged += new DataGridPageChangedEventHa
FIRST.Click += new System.EventHandler(this.f
NEXT.Click += new System.EventHandler(this.N
PREVIOUS.Click += new System.EventHandler(this.p
LAST.Click += new System.EventHandler(this.l
frst.Click += new System.EventHandler(this.N
prev.Click += new System.EventHandler(this.N
nxt.Click += new System.EventHandler(this.N
las.Click += new System.EventHandler(this.N
if(!IsPostBack)
{
CurrentPage = 0;
//DGrid_PageIndexChanged += new DataGridPageChangedEventHa
//DGrid.DataBind();
}
}
//#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>
///
protected void InitializeComponent()
{
System.Configuration.AppSe
this.Conn = new System.Data.SqlClient.SqlC
this.sqlCo = new System.Data.SqlClient.SqlC
this.DTable = new System.Data.DataTable();
this.DataA = new System.Data.SqlClient.SqlD
this.DataS2 = new System.Data.DataSet();
this.DTable2 = new System.Data.DataTable();
this.DSet2 = new Appl.DSet2();
((System.ComponentModel.IS
((System.ComponentModel.IS
((System.ComponentModel.IS
((System.ComponentModel.IS
this.QueryMe.DataBinding += new System.EventHandler(this.Q
this.QueryMe.Click += new System.EventHandler(this.Q
this.BCal.Click += new System.EventHandler(this.B
this.DGrid.PageIndexChange
this.DGrid.SelectedIndexCh
//
// Conn
//
this.Conn.ConnectionString
//
// sqlCo
//
this.sqlCo.CommandText = ((string)(configurationApp
this.sqlCo.CommandTimeout = ((int)(configurationAppSet
this.sqlCo.Connection = this.Conn;
//
// DTable
//
this.DTable.Namespace = ((string)(configurationApp
this.DTable.TableName = ((string)(configurationApp
//
// DataA
//
this.DataA.AcceptChangesDu
this.DataA.ContinueUpdateO
this.DataA.TableMappings.A
new System.Data.Common.DataTab
new System.Data.Common.DataCol
new System.Data.Common.DataCol
new System.Data.Common.DataCol
new System.Data.Common.DataCol
new System.Data.Common.DataCol
//
// DataS2
//
this.DataS2.DataSetName = ((string)(configurationApp
this.DataS2.Locale = new System.Globalization.Cultu
this.DataS2.Namespace = ((string)(configurationApp
this.DataS2.Tables.AddRang
this.DTable2});
//
// DTable2
//
this.DTable2.Namespace = ((string)(configurationApp
this.DTable2.TableName = ((string)(configurationApp
//
// DSet2
//
this.DSet2.DataSetName = "DSet2";
this.DSet2.Locale = new System.Globalization.Cultu
this.Load += new System.EventHandler(this.P
this.PreRender += new System.EventHandler(this.P
((System.ComponentModel.IS
((System.ComponentModel.IS
((System.ComponentModel.IS
((System.ComponentModel.IS
}
public void Calc_Click(Object Sender, EventArgs e)
{
Eq1.Text = (double.Parse(TI.Text) + double.Parse(DRST.Text)).T
Eq2.Text = (double.Parse(TI.Text) - double.Parse(DRST.Text)).T
}
public void Add_Click (object sender, EventArgs e)
{
Eq1.Text = (double.Parse(Ret1.Text) + double.Parse(Tol1.Text)).T
}
public void Add_Subtract (object sender, EventArgs e)
{
Eq2.Text = (double.Parse(Ret2.Text) - double.Parse(Tol1.Text)).T
}
public void interger (object sender, EventArgs el)
{
int DefFrom = -1000000;
int DefTo = 100000000;
try
{
int F;
int T;
F = Eq1.Text.Trim().Length==0?
T = Eq2.Text.Trim().Length==0?
//string sql = "select * from Waveplate";
//sql += "where Retardation >" +From.ToString();
//sql += "and field2 <" +to.ToString();
}
catch (System.Exception e)
{
Response.Write(e.Message);
}
}
protected void QueryMe_Click(object sender, EventArgs e)
{
int CIndex = 0;
int pageSize = 10;
Conn.Open();
//string LRecord = DSet2.Tables["Waveplate"].
string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')order by Physical_Location";
//"(Select * from Waveplate where (Retardation between " + Eq2.Text + " and " + Eq1.Text + ")) and Diameter = '" + Diameter.Text + "') or ((Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')order by Physical_Location";
//string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')";
//string sqlC = String.Format("(select * from Waveplate where Retardation between {0} and {1} and {2} = Diameter)", Eq1.Text, Eq2.Text , Diameter.Text) ;
DataA = new System.Data.SqlClient.SqlD
//SqlCommand CommandText = Conn.CreateCommand();
//sqlC.Connection = Conn;
//string Q = "select * from Main_Wave_Inv (Retardation,Retardation)(
//SqlCommand sqlCom = new SqlCommand(sqlC, Conn);
//string SQ = System.Configuration.Confi
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C
CIndex += pageSize;
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To
DataA.Fill(DataS2, CIndex, CurrentPage, "Waveplate");
DGrid.DataSource = DataS2;
DGrid.DataMember = "Waveplate";
DataView MiDView = DataS2.Tables["Waveplate"]
int Rcount = MiDView.Table.Rows.Count;
LabelC.Text = Rcount.ToString();
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To
//DGrid.CurrentPageIndex = DGrid.Page;
//DataS["Timestamp"] = DateTime.Now.Date.ToLocalT
//DTable.Clear();
//DTable.Columns.Clear();
int RCount = DataS2.Tables["Waveplate"]
//LabelC.Text = RCount.ToString();
DataS2.Tables.Add();
DGrid.DataBind();
//Session["Waveplate"]= DataS2;
string LastRecord = DataS2.Tables["Waveplate"]
DGrid.VirtualItemCount.ToS
//ViewState["LastKey"] = DGrid.DataKeys[DGrid.Items
//ViewState["FirstKey"] = DGrid.DataKeys[-1];
//int Physical_Location = Convert.ToInt32(ViewState[
//int Physical_Location = Convert.ToInt32(ViewState[
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla
/*if (DGrid.Items.Count < DGrid.PageSize)
{
NEXT.Enabled = false;
}
else
{
LAST.Enabled = false;
}*/
Conn.Close();
}
//this.Dcol.DataType = MiSqlDReader.GetFieldType(
//this.Dcol.ColumnName = MiSqlDReader.GetName(i);
//this.Dset.Tables(Main_Wa
//}
//public System.Data.DataTable GetTable(System.Data.SqlCl
//{
//}
//catch(System.Exception ex)
//{
// Response.Write(ex.Message)
//........Messagebox.Show(
//#endregion
//RcdCount = DS.Tables("pubs").Rows.Cou
//totalCount=ds.Tables["Pe
private void BCal_Click(object sender, EventArgs e)
{
try
{
//snD.Text = (double.Parse(.0088641 + .000107057) * (DL.Text)^2+1.9893*(.00000
double dr = Double.Parse(DR.Text);
double dl = Double.Parse(DL.Text);
double dt = Double.Parse(DT.Text);
double sn = Double.Parse(snD.Text);
double d = Double.Parse(d0.Text);
double s = Double.Parse(sT.Text);
double m = Double.Parse(MT.Text);
double dx = Double.Parse(dy.Text);
double ct = Double.Parse(cte.Text);
double sn2 = Double.Parse(snM.Text);
double m1 = Double.Parse(ML.Text);
double m2 = Double.Parse(MR.Text);
double d1 = Double.Parse(dd0.Text);
double drs = Double.Parse(DRST.Text);
double d2 = Double.Parse(dd.Text);
double mrt = Double.Parse(MRST.Text);
//snD.Text = double.Parse(snD.Text).ToS
//int z;
//z = 1000;
//TBox.Text = z.ToString();
//m1/z
//DL.Text = (double.Parse(Wavelength.T
//sn = (.0088641 + 1.07057 * (.0001)/(dl * dl) + (1.9893 *.000001)/(dl*4*4) - .00017175*(dl*dl)-(dt) * .000001*1+dt/900*(1.01+0.2
//sn = (Double.Parse("8.8641E-03"
sn =8.8641*10e-4+1.07057*(10e
d = (dr*dl)/sn;
//s = (dt-m);
s = (m-dt);
dx = d*(1+ct*s);
//sn2 = (Double.Parse("8.8641E-03"
sn2 = 8.8641*10e-4+1.07057*(10e-
m2 = (sn2*dx)/m1;
d1 = (drs*dl)/sn;
d2 = d1*(1+ct*s);
mrt = (sn2*d2)/m1;
//snD.Text = snD.Text.ToString();
//sT.Text = (double.Parse(MT.Text) - double.Parse(DT.Text)).ToS
snD.Text = sn.ToString();
d0.Text =d.ToString();
dd.Text = d2.ToString();
DRST.Text = drs.ToString();
snM.Text = sn2.ToString();
MRST.Text = mrt.ToString();
dy.Text = dx.ToString();
sT.Text = s.ToString();
MR.Text = m2.ToString();
dd0.Text = d1.ToString();
//int DefFrom = -1000000;
Eq1.Text = (double.Parse(TI.Text) + double.Parse(DRST.Text)).T
Eq2.Text = (double.Parse(TI.Text) - double.Parse(DRST.Text)).T
TI.Text=MR.Text;
}
catch (FormatException ex)
{
//ex.Message = "FormatException" + ex;
//MessageBox.Show("Message
Response.Write("Error Message is" + ex.ToString());
Response.Write(ex.Message)
}
}
private void Conn_InfoMessage(object sender, System.Data.SqlClient.SqlI
{
}
private void Eq1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
//Checkbox update function
//OleDbCommand c = new OleDbCommand("UPDATE Item SET Status='Loan'", con);
//con.Open();
//c.ExecuteNonQuery();
/* string key = DGrid.DataKeys[e.Item.Item
string Sq;
Sq = "Update [Waveplate]" +
"set Reserve_User =?, Reserve_User =?," +
"Inventory_Status=?, Inventory_Status=R"+
"where Part_Key =?, and Physical_Location=?";
SqlCommand SCom = new SqlCommand(Sq, Conn);
SqlParameterCollection CSql = SCom.Parameters;
CSql.Add("Inventory_Status
CSql.Add ("Reserve_Time", SqlDbType.DateTime);
DataA.Update(DataS, "Waveplate");
DataS.AcceptChanges();*/
}
public void Edit_Click(Object source, System.Web.UI.WebControls.
{
DGrid.EditItemIndex = e.Item.ItemIndex;
BindIt();
}
/* public void DGrid_ItemDataBound(object
System.Web.UI.WebControls.
{
if(e.Item.ItemType == ListItemType.EditItem)
{
DataRowView drv = (DataRowView) e.Item.DataItem;
String currentgenre = drv["Inventory_Status"].To
DropDownList ddl =
(DropDownList) e.Item.FindControl("DropDo
ddl.SelectedIndex =
ddl.Items.IndexOf(ddl.Item
}
}
*/
protected void OnUpdate_Click(Object source, System.Web.UI.WebControls.
{
DateTime DT = DateTime.Now;
string ToDa = DT.ToString("mm/dd/yyyy hh:nn:ss");
string Inv;
//bool Discon=((CheckBox)e.Item.F
string Key = DGrid.DataKeys[e.Item.Item
TextBox box;
//DropDownList = box;
box = (TextBox)(e.Item.Cells[1].
Inv=box.Text;
//Label L;
//ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Item
// Gets the value the TextBox control in the 7th column
//Convert.ToDateTime((e.It
//Convert.ToDateTime(e.Ite
//L.Text = ToDa;
ToDa = ToDa.ToString();
string Sq;
Sq = "Update Waveplate set Inventory_Status=@Inventor
//Reserve_Timestamp = "+"'GetDate()'"+
//Sq = "Update [Waveplate]" + "set Inventory_Status=@Inventor
//"where Part_Key =@Part_Key";
SqlCommand SCom = new SqlCommand(Sq, Conn);
//SqlParameterCollection CSql = SCom.Parameters;
SCom.Parameters.Add("@Part
SCom.Parameters["@Part_Key
SCom.Parameters.Add("@Inve
SCom.Parameters["@Inventor
//SCom.Parameters.Add("@Re
//SCom.Parameters["@Reserv
SCom.Parameters["@Part_Key
SCom.Connection.Open();
try
{
SCom.ExecuteNonQuery();
Response.Write ("<b></b><br>" + Sq);
DGrid.EditItemIndex = -1;
}
catch (SqlException E)
{
if (E.Number == 2627)
Response.Write("ERROR: ");
else
Response.Write ("ERROR: ");
}
SCom.Connection.Close();
BindIt();
}
//DataA.Update(DataS, "Waveplate");
//DataS.AcceptChanges();
public void DGrid_PageIndexChanged(obj
{
DGrid.CurrentPageIndex = e.NewPageIndex;
DataBind();
}
public void CancelIt(Object sender, DataGridCommandEventArgs e)
{
DGrid.EditItemIndex = -1;
BindIt();
}
protected void DGrid_Checked(object sender, System.EventArgs e)
{
/* //CType(y.Item.ItemType = )
int Rcount = 0;
StringBuilder DGridMe = new StringBuilder();
//int Part_Key =(int)DGrid.DataKeys[(int)
//bool Reserved=((CheckBox)e.Item
//CheckBox CBox = (ck) e.Item.FindControl("Invent
//Binding CheckBind = new Binding("Check", DSet,"Waveplate.Inventory_
//ck.DataBindingsAdd(Check
//findout the selected item index and bindgrid again
//DGrid.EditItemIndex = (int)y.Item.ItemIndex;
//CheckBox checkbx;
foreach (DataGridItem DGridItem in DGrid.Items)
{
CheckBox Ccheck = (CheckBox)DGridItem.Cells[
//DataRow ro;
//TextBox t;
t = (TextBox)DGridItem.Cells[2
//ck(e.Item.Cells[6].Contr
//DataGridItem DGI = DGrid.Items[i].FindControl
//ck = (y.Item.FindControl());
//CBox.Checked
//bool CValu;
//string K = DGrid.DataKeys[y.Item.Item
if(Ccheck.Checked == true)
{
Rcount++;
Ccheck.Text = "Reserv";
DGridMe.AppendFormat("Chec
DGridMe.AppendFormat("Tota
}
}
//DGridMe.AppendFormat("To
DGridMe.Append("<hr>");
L1.Text = DGridMe.ToString();
//DGridMe.AppendFormat("Ch
}
private void dd_TextChanged(object sender, System.EventArgs y)
{
//UpdateCommand.Parameters
/*<asp:TemplateColumn HeaderText="Reservation">
<ItemTemplate><asp:Checkbo
Checked ='<%#DataBinder.Eval(Conta
//if ck.Checked = DGrid.EditItemIndex = -1;
//DataBind();
}
public void btnUpdate_Click(object sender, System.EventArgs e)
{
int i;
DataGridItem dgi;
int bookid;
TextBox TextBoxTitle;
CheckBox ChInv;
TextBox TextBoxPrice;
string Sq2;
Sq2 = "Update Waveplate set Inventory_Status=@Inventor
SqlCommand SCom2 = new SqlCommand(Sq2, Conn);
for(i = 0; i <= DGrid.Items.Count -1 ; i++)
{
dgi = DGrid.Items[i];
Label LabelBookId = (Label) dgi.Cells[0].Controls[1];
bookid = int.Parse(LabelBookId.Text
TextBoxTitle = (TextBox) dgi.FindControl("TextBoxTi
ChInv = (CheckBox) dgi.FindControl("CheckBoxI
TextBoxPrice = (TextBox) dgi.FindControl("TextBoxPr
//this.dcmdUpdateBooks.Par
//this.dcmdUpdateBooks.Par
SCom2.Parameters["@Invento
ChInv.Checked;
ChInv.Text = "R";
//this.dcmdUpdateBooks.Par
float.Parse(TextBoxPrice.T
this.Conn.Open();
SCom2.ExecuteNonQuery();
this.Conn.Close();
}
}
public void BindIt()
{
Conn.Open();
string sqlC = "(select Top 30 * from Waveplate where ((Retardation between " + Eq2.Text + " and " + Eq1.Text + ") or (Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')";
//string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')";
//string sqlC = String.Format("(select * from Waveplate where Retardation between {0} and {1} and {2} = Diameter)", Eq1.Text, Eq2.Text , Diameter.Text) ;
DataA = new System.Data.SqlClient.SqlD
//SqlCommand CommandText = Conn.CreateCommand();
//sqlC.Connection = Conn;
//string Q = "select * from Main_Wave_Inv (Retardation,Retardation)(
//SqlCommand sqlCom = new SqlCommand(sqlC, Conn);
//string SQ = System.Configuration.Confi
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C
DataA.Fill(DataS2, "Waveplate");
DGrid.DataSource = DataS2;
DGrid.DataMember = "Waveplate";
DTable.Clear();
DTable.Columns.Clear();
DataS2.Tables.Add();
DGrid.DataBind();
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla
Conn.Close();
}
/*private void btnUp_Click(object sender, System.EventArgs e)
{
int i;
DataGridItem dgi;
int bookid;
//Rest of declarations here
for(i = 0; i <= DGrid.Items.Count -1 ; i++)
{
dgi = DGrid.Items[i];
TableCell tc = dgi.Cells[0];
string s = dgi.Cells[0].Text;
Label LabelBookId = (Label) dgi.Cells[3].Controls[1];
bookid = int.Parse(LabelBookId.Text
if (bookidlist.Contains(booki
{
// Update code here
}
}
}
protected void RowChanged( object sender, System.EventArgs e)
{
DataGridItem dgi = (DataGridItem)(((Control)s
Label bookidlabel = (Label) dgi.Cells[3].Controls[1];
int Part_Key = int.Parse(bookidlabel.Text
if (!bookidlist.Contains(Part
{
bookidlist.Add(Part_Key);
}
}*/
public void ck_Click(object sender, System.EventArgs e)
{
//if (ck.Checked)
// Inventory_Status.
}
private void dy_TextChanged(object sender, System.EventArgs e)
{
}
/*public static void GetData(string direction)
{
sqlCo.Parameters.Clear();
switch(direction)
{
case "Next":
sqlCo.CommandText = "(Select * from Waveplate where ((Retardation between " + Eq2.Text + " and " + Eq1.Text + ") or (Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')";
sqlCo.Parameters.Add("@Par
break;
case "Previous":
sqCo.CommandText = "(Select * from Waveplate where ((Retardation between " + Eq2.Text + " and " + Eq1.Text + ") or (Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')";
sqlCo.Parameters.Add("@Par
break;
}
}*/
private void DR_TextChanged(object sender, System.EventArgs e)
{
}
public void prev_Click(object sender, System.EventArgs e)
{
if
(DGrid.CurrentPageIndex > 0)
{
DGrid.CurrentPageIndex -=1;
DataBind( );
}
}
public void last_Click(object sender, System.EventArgs e)
{
if (DGrid.CurrentPageIndex< DGrid.PageCount -1)
{
DGrid.CurrentPageIndex = DGrid.PageCount -1;
DataBind();
}
}
public void Next_OnClick(object sender, EventArgs e)
{
if (DGrid.CurrentPageIndex < DGrid.PageCount -1)
{
}
DGrid.CurrentPageIndex += 1;
sqlC.CommandText = "Select Top" +pageSize+" * from Waveplate"+
"where Physical_Location > @Physical_location Order By Physical_Location";
sqlC.Parameters.Add("@Phys
}
public void first_Click(object sender, EventArgs e)
{
if (DGrid.CurrentPageIndex <0)
{
DGrid.CurrentPageIndex = 0;
Bind();
}
}
private void NavigationButtonClick(obje
{
string direction = ((Button)sender).CommandNa
switch (direction.ToUpper())
{
case "frst" :
DGrid.CurrentPageIndex = 0;
break;
case "prev" :
DGrid.CurrentPageIndex =
Math.Max(DGrid.CurrentPage
break;
case "nxt" :
DGrid.CurrentPageIndex =
Math.Min(DGrid.CurrentPage
DGrid.PageCount - 1);
break;
case "las" :
DGrid.CurrentPageIndex = DGrid.PageCount - 1;
break;
default :
break;
}
}
protected void Bind()
{
int CIndex = 0;
int pageSize = 10;
Conn.Open();
//string LastRecord = DSet2.Tables["Waveplate"].
string sqlCo = "(SELECT * From Waveplate where Physical_Location > "+LastRecord+") order by Physical_Location";
//DataA.SelectCommand.Comm
//DataS2.Tables["Waveplate
//sqlC2.Parameters.Add("@P
//"(Select * from Waveplate where (Retardation between " + Eq2.Text + " and " + Eq1.Text + ")) and Diameter = '" + Diameter.Text + "') or ((Retardation between " + Eq1.Text + " and " + Eq2.Text + ")) and Diameter = '" + Diameter.Text + "')order by Physical_Location";
//string sqlC = "(select * from Waveplate where Retardation between " + Eq2.Text + " and " + Eq1.Text + " and Diameter = '" + Diameter.Text + "')";
//string sqlC = String.Format("(select * from Waveplate where Retardation between {0} and {1} and {2} = Diameter)", Eq1.Text, Eq2.Text , Diameter.Text) ;
DataA = new System.Data.SqlClient.SqlD
//SqlCommand CommandText = Conn.CreateCommand();
//sqlC.Connection = Conn;
//string Q = "select * from Main_Wave_Inv (Retardation,Retardation)(
//SqlCommand sqlCom = new SqlCommand(sqlC, Conn);
//string SQ = System.Configuration.Confi
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C
CIndex += pageSize;
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To
DataA.Fill(DataS2, CIndex, pageSize, "Waveplate");
DGrid.DataSource = DataS2;
DGrid.DataMember = "Waveplate";
DataView MiDView = DataS2.Tables["Waveplate"]
int Rcount = MiDView.Table.Rows.Count;
LabelC.Text = Rcount.ToString();
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To
//DGrid.CurrentPageIndex = DGrid.Page;
//DataS["Timestamp"] = DateTime.Now.Date.ToLocalT
//DTable.Clear();
//DTable.Columns.Clear();
int RCount = DataS2.Tables["Waveplate"]
//LabelC.Text = RCount.ToString();
DataS2.Tables.Add();
DGrid.DataBind();
//Session["Waveplate"]= DataS2;
//string LastRecord = DataS2.Tables["Waveplate"]
DGrid.VirtualItemCount.ToS
//ViewState["LastKey"] = DGrid.DataKeys[DGrid.Items
//ViewState["FirstKey"] = DGrid.DataKeys[-1];
//int Physical_Location = Convert.ToInt32(ViewState[
//int Physical_Location = Convert.ToInt32(ViewState[
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla
/*if (DGrid.Items.Count < DGrid.PageSize)
{
NEXT.Enabled = false;
}
else
{
LAST.Enabled = false;
}*/
Conn.Close();
}
}
}
ASKER
The IListSource does not contain a data source name
The error above is what happens when I add DGrid.DataBind(); and the datasource..
Any suggestions?????
The error above is what happens when I add DGrid.DataBind(); and the datasource..
Any suggestions?????
can you most the code that you have tried to execute - what datasource have you put on your_datasource ?
B..M
B..M
ASKER
I used DGrid.DataSource = DataS2; and DGrid.DataBind();
Is it better to used stored procedures for custom paging???
Thanks
Is it better to used stored procedures for custom paging???
Thanks
the error means that DataS2 is null when you call DataBind method
debug the application and check it
B..M
debug the application and check it
B..M
ASKER
What I have done is bind the navigation to the function below and now I get an sql statement error, how should I set up the sql statement to read the data
what the paging process begins?????
protected void Bind()
{
SqlConnection DConn =null;
SqlDataAdapter SDa = null;
int CIndex = 0;
int pageSize = 10;
Conn.Open();
//string LastRecord = DSet2.Tables["Waveplate"]. Rows[pageS ize -1]["Physical_Location"].T oString();
string sqlCo = "SELECT Top"+pageSize+ "* From Waveplate ";
DataA = new System.Data.SqlClient.SqlD ataAdapter (sqlCo, Conn);
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C onn) ;
CIndex += pageSize;
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To String()] = DGrid.Items[0].Cells[0].Te xt;
DataA.Fill(DataS2, CIndex, pageSize, "Waveplate");
DGrid.DataMember = "Waveplate";
DataView MiDView = DataS2.Tables["Waveplate"] .DefaultVi ew;
int Rcount = MiDView.Table.Rows.Count;
LabelC.Text = Rcount.ToString();
ViewState["CurrentPage"] = CurrentPage;
int RCount = DataS2.Tables["Waveplate"] .Rows.Coun t;
DGrid.DataSource = DataS2;
DataS2.Tables.Add();
DGrid.DataBind();
DGrid.VirtualItemCount.ToS tring();
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla te");
/*if (DGrid.Items.Count < DGrid.PageSize)
{
NEXT.Enabled = false;
}
else
{
LAST.Enabled = false;
}*/
Conn.Close();
}
what the paging process begins?????
protected void Bind()
{
SqlConnection DConn =null;
SqlDataAdapter SDa = null;
int CIndex = 0;
int pageSize = 10;
Conn.Open();
//string LastRecord = DSet2.Tables["Waveplate"].
string sqlCo = "SELECT Top"+pageSize+ "* From Waveplate ";
DataA = new System.Data.SqlClient.SqlD
DataTable DTable = new DataTable();
//sqlC.CommandText = "Select * from Main_Wave_Inv, Conn"; //(Retardation, Retardation)(@Eq1,@Eq2)",C
CIndex += pageSize;
ViewState["CurrentPage"] = CurrentPage;
//ViewState[CurrentPage.To
DataA.Fill(DataS2, CIndex, pageSize, "Waveplate");
DGrid.DataMember = "Waveplate";
DataView MiDView = DataS2.Tables["Waveplate"]
int Rcount = MiDView.Table.Rows.Count;
LabelC.Text = Rcount.ToString();
ViewState["CurrentPage"] = CurrentPage;
int RCount = DataS2.Tables["Waveplate"]
DGrid.DataSource = DataS2;
DataS2.Tables.Add();
DGrid.DataBind();
DGrid.VirtualItemCount.ToS
//SqlDataAdapter DataA = new SqlDataAdapter("Select * from Waveplate", Conn);
//DataA.Fill(Dset,"Wavepla
/*if (DGrid.Items.Count < DGrid.PageSize)
{
NEXT.Enabled = false;
}
else
{
LAST.Enabled = false;
}*/
Conn.Close();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the problem is that you don't set a datasource ( as far as i saw ) to the datagrid in
public void DGrid_PageIndexChanged(obj
{
DGrid.CurrentPageIndex = e.NewPageIndex;
//DGrid.DataSource = your_datasource;
DGrid.DataBind();
}
Regards!
B..M