I am trying to page my results. However, my Next Link and my Last Link always bring up my first page. I cannot get to the second page of results.
Might anyone have any idea as to what I am doing wrong?
publicpartialclass _Default : System.Web.UI.Page
#region Web Form Designer generated code
protected System.Web.UI.WebControls.RadioButton rdoProduct;
protected System.Web.UI.WebControls.Image Image1;
///<summary>/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
this.cmdSearch.Click += new System.EventHandler(this.cmdSearch_Click);
this.Load += new System.EventHandler(this.Page_Load);
#region "Local Variables and Declarations"
privateconstbool blnAllowPaging = true;
privateconstint iPageSize = 5;
PagedDataSource pgdProducts = new PagedDataSource();
protectedvoid Page_Load(object sender, EventArgs e)
//Hide results controls
rptClasses.Visible = false;
lblMessage.Text = "";
//set previous link, next link and page# labels to invisible.
lblCurrentPage.Visible = true;
lnkNext.Visible = true;
lnkPrevious.Visible = true;
//Populate within values (real app would pull from DB)
cboWithin.Items.Add("Only this zip");
cboWithin.Items[cboWithin.Items.Count - 1].Value = "0";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "5";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "10";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "25";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "50";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "100";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "200";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "999";
#region "Footer LinkButtons"
protectedvoid lnkFirst_Click(object sender, EventArgs e)
//Set viewstatevariable to the next page.
NowViewing = 0;
protectedvoid lnkPrev_Click(object sender, EventArgs e)
//Set viewstatevariable to the next page.
//CurrentPage -= 1;
protectedvoid lnkNext_Click(object sender, EventArgs e)
//Set viewstatevariable to the next page
//CurrentPage += 1;
protectedvoid lnkLast_Click(object sender, EventArgs e)
//Set viewstatevariable to the previous page
NowViewing = pgdProducts.PageCount - 1;
#region "Footer DropDownList"
protectedvoid ddlpageNumbers_SelectedIndexChanged(object sender, EventArgs e)
//pgdProducts.PageSize = int.Parse(ddlpageNumbers.SelectedValue);
NowViewing = ddlpageNumbers.SelectedIndex;
#region "Custom Functions"
pgdProducts.AllowPaging = blnAllowPaging;
pgdProducts.PageSize = iPageSize;
pgdProducts.DataSource = GetProductsDataView();
pgdProducts.CurrentPageIndex = NowViewing;
//lblTotalPages.Text = pgdProducts.PageCount.ToString();
//tell what page number the user is on and how many pages of results there are total.
//lblCurrentPageBottom.Text = "Showing Page " + CurPage.ToString() + " of " + pagesCount + " ";
lblCurrentPage.Text = "Now Showing Page " + (NowViewing + 1).ToString() + " of " + pgdProducts.PageCount.ToString();
lblItemsPerPage.Text = (pgdProducts.Count).ToString() + " items per page.";
//lblTotalItemCount.Text = (objPds.Count * objPds.PageCount).ToString() + " total number of items that your search returned.";
lblTotalItemCount.Text = (pgdProducts.DataSourceCount).ToString() + " total number of items that your search returned.";
lnkFirst.Enabled = !pgdProducts.IsFirstPage;
lnkPrevious.Enabled = !pgdProducts.IsFirstPage;
lnkNext.Enabled = !pgdProducts.IsLastPage;
lnkLast.Enabled = !pgdProducts.IsLastPage;
ddlpageNumbers.SelectedIndex = pgdProducts.CurrentPageIndex;
rptClasses.DataSource = pgdProducts;
private DataView GetProductsDataView()
DataTable dtProductsTemp = new DataTable();
using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]))
using (SqlDataAdapter adapProducts = new SqlDataAdapter("cmd", conn))
SqlParameter arParms = new SqlParameter;
arParms = new SqlParameter("@Zipcode", SqlDbType.Char);
arParms.Value = txtZipCode.Text;
arParms = new SqlParameter("@Miles", SqlDbType.Decimal);
arParms.Value = Int16.Parse(cboWithin.SelectedItem.Value);
arParms = new SqlParameter("@Subject", SqlDbType.Char);
arParms.Value = txtSearchWords.Text;
DataSet ds = new DataSet();
ds = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["ClassesnWorkshops.Properties.Settings.ConnectionString"].ConnectionString,
CommandType.StoredProcedure, "spHouses_GetNearZipcode", arParms);
dtProductsTemp = ds.Tables;
privatevoid FillPagesDropDownList(int iTotalPages)
for (int i = 1; i <= iTotalPages; i++)
ddlpageNumbers.Items.Add(new ListItem(i.ToString(), i.ToString()));
object obj = ViewState["_NowViewing"];
if (obj == null)
this.ViewState["_NowViewing"] = value;
//this.thisPageNumber = value;
protectedvoid cmdSearch_Click(object sender, EventArgs e)
DataTable objDT = null;
//Query the database for classes
objDT = GetProductsDataView().ToTable();
//Any classes found?
if (objDT.Rows.Count == 0)
//None found - hide repeater, show message
rptClasses.Visible = false;
lblMessage.Text = "No results found";
// //Houses found - show repeater, hide message
rptClasses.Visible = true;
lblMessage.Text = "";
catch (Exception ex)
//Add your own error handling here
lblMessage.Text = "Error: " + ex.ToString();
objDT = null;
I've got it!
It was not so much a code issue, as a VisualStudio.Net issue. I hard coded the Click Event for the lnkNext. For some reason, VisualStudio was ignoring this code, so my Next Link was doing nothing (thus the first page was returned again).
I needed to double click the linkButton control so that Visual Studio automatically created the Click Event for the control. Now it recognizes what the Next Link is supposed to do and gives me page 2!
fraud checking is done using checksums and the like
What a simplistic idea! Just think of a freshly stolen credit card which has not yet been reported stolen. Or a "copied" credit card, or some hacker using the credit card number for purchases in the web... Here you'll need some highly sophisticated heuristics.
I think you meant "artificial intelligence" systems and not "artificial immune" systems.
As has already been mentioned, this is a wide subject and cannot be explained a reply to your post. I suggest you begin by reading some of the papers and books mentioned in the Reference section on this[^] page.
Depends on a huge number of factors: primarily the physical size of the label you are going to print. If it's only one inch by 1/4 inch, that eliminates a lot of versions.
The link Richard gave you covers a lot of the variants: start there and do some research!
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
I have a C# and Silverlight project with two combo boxes (CB1, CB2)
-CB1 is initialized and populated with few items.
(e.g. car, plane, motorcycle)
-User selects an item (e.g. car) and CB2 gets automatically populated
(e.g. model, year, color) via the cb1_SelectionChanged()
-user selects the item from CB2 (e.g. model) and a datagid is populated accordingly.
Once I selected item from CB2 and datagrid is populated correctly, attempting to select a different item from CB1 generates a “Object reference not set to an instance of an object”
To go around just select a different item then back again to the item and that woks but is really annoying. :)
Any ideas will be greatly appreciated
Comboboxes use to send two SelectionChanged events when the user changes the selection: in the first event, the previously selected item is un-selected, at this moment no item is selected, comboBox1.SelectedItem is null, and consequently comboBox1.SelectedItem.ToString(); causes a NullReferenceException.
Then the new item gets selected and SelectedItem has a value again.
Solution: check SelectedItem for null.
I understand you aren't going to be able to give me a specific answer, but I am kind of stunned at this point...
I work on a library that has competitors. Our APIs are pretty similar. I call MyLibrary.MethodA() 1,000,000 times. It takes 1000ms. I call MyCompetitor.MethodA() 1,000,000 times and it takes 150ms. Both in Debug / Any CPU.
I'm trying to figure out where my overhead is. So in MethodA() I tried returning just null at the beginning. That was already 16ms. MethodA calls an internal method which calls another one, etc. Basically, the only thing I'm doing at the top level methods is checking the params for null. Then I lock a dictionary and do a TryGetValue. At this point I start getting to the method that starts doing real work. I'm already at 195ms and am returning null.
How is that even possible? The other guy is returning 150ms and actually doing the work. I'm at 195ms and returning null from an empty method???
For other CPians to help and give you useful suggestions, you have to give more context what the method is doing and what algo it is using and does it access the network to access the DBMS? Does it use LINQ? Does it use reflection? Does it use C++/CLI interop? etc...
Yes, as I said, I haven't gotten to optimizing the algorithm itself yet .
Just calling EMPTY methods in my DLL is slower then calling the other guys FULL method. That's where I'm confused.
His FULL method is 150ms for 1,000,000x.
I'm just calling 4 pretty empty methods. Method1 does nothing but call Method2 (a generic method calling the non generic version). Method2 calls Method3 which just checks that the param is not null and then calls Method4. Method4 locks on a dictionary and calls TryGetValue() (Key = Type, Value = Info class). If it can't find the Info class in the dictionary, it news one up. Now it calls Method5. At this point, I haven't even done the work yet, just getting set up and I'm already at 111ms. The other guy is already done completely at 150ms. That's what I'm puzzled about. Haven't even gotten to any code that I can optimize yet .
He might be caching some data in memory - it could be slower when you call the method only once, but surely speeds up when the method is called a million times.
Are you sure that the competitor's method is thread-safe?
If I understand this correctly, you are calling you method 1 million times and it takes one second. So 1 microsecond to execute. That doesn't sound like a lot to me, but without knowing what it does who knows.
At such speeds, dictionary lookups start to become quite heavy duty operations. I would think locking the dictionary would start to have a bad impact as well (I've got the time 80ns in my head, but that's probably wrong).
Remember that for each look up, the dictionary might call GetHashCode() and Equals() on multiple objects so you need to make sure that your implementations of these things are very efficient.
Bin the dictionary and switch to non-locking synchronization if possible. Also, get Reflector or something on the competitors assembly and see what's happening.
The entire delegate would be executed within the scope of a lock, as with your non-generic dictionary code. However, the lock would be more granular, based on the number of buckets and the concurrency level of the collection.
If you wanted to execute the "other stuff" outside of the lock, your code would look like:
if (!concurrentDict.TryGetValue(theKey, out theValue))
var theNewObject = NewUpAnObject(theKey);
theValue = concurrentDict.GetOrAdd(theKey, theNewObject);
// theValue = concurrentDict.GetOrAdd(theKey, key => NewUpAnObject(key));
In this case, DoSomeOtherStuff, DoAFewMoreThings and NewUpAnObject would run outside of any lock. However, the insert to the dictionary would not suffer from a race condition, as the class is specifically written to cope with this type of code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
There are many, many areas that could contribute. Your competitor might delegate all calls to background threads, for instance, giving the appearance that they are processing quickly. They might be using highly optimised native code behind the scenes (after all, just because you've compiled to debug, it doesn't mean your competitor has shipped you a debug version of their code, so you're comparing apples with the Mona Lisa).
You mean compiling it to x86 or x64 rather then Any CPU? It just seems like I've got overhead calling empty functions. I'm not sure they can kick off background threads as they need to return an object from the method.
No, I mean that they might be using C++ (for instance). Also, if you compile your code to release version and then compare against theirs, you should get more realistic timings. I guarantee you that their version will be the release version.
I am trying to get "Command" values of each table with [table row(tr) and standard cell(td) which has valiagn="top"] tags defined from this website: Console Command List - Valve Developer Community[^].
So, at the end I want a whole list of "Commands" names stored in a string separated with a new line character (CR+LF). Here I took a screenshot[^].
Last Visit: 31-Dec-99 18:00 Last Update: 28-Sep-16 8:54