July 2004 - Posts

Get all selected values checkboxList

Hey all,

I had a small problem when working with a check box list  because when you say CheckBoxList1.SelectedValue you only get the first value selected not all the selected values.
To get all the selected values u will need to go true all the items like the following code dues

foreach(ListItem item in ((CheckBoxList1)Page.FindControl(dr.id.ToString())).Items)
{
    if (item.Selected)
    {
           Label1.Text += item.Value+“, “;
     }
}

Why isn't there just a way to get like CheckBoxList1.SelectedValues and get back a array with all selected values? A wll you can't have it all

Happy netting,
Warnar

Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Hey all,

I got the following error when working with access
Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

My query was ok but i seems i used a reserved word in my query the way to get the query to work is using [ ] before and after that word.

Got the solution form  http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21023377.html

Happy netting,
warnar

Moving a Row up in a Datatable

Hey all,

I was bizzy with a little project and it needed to move row's up and down in a Datarow.
Problem was i couldn't move the datarows so i needed to move the info.
The way i moved a row up was like this (this happend in ItemCommand with a command named Up):

object[] up = DataTableFields.Rows[e.Item.ItemIndex].ItemArray;
object[] down = DataTableFields.Rows[e.Item.ItemIndex-1].ItemArray;
DataTableFields.Rows[e.Item.ItemIndex].ItemArray = down;
DataTableFields.Rows[e.Item.ItemIndex-1].ItemArray = up;

Don't really like this way but hey it works.

Happy netting,
warnar

No LIMIT in MSSQL how to do the same

Hey all,

I was having the small problem with a site with alot of records in the DB and well i pulled them out every time the site was shown but it was only showing 10 records not all.
The problem was that i could use the same SQL as in ASP.NET DataGrid Paging Part 2 - Custom Paging because i neede couldn't use ID's that way.

So i neede to get 10 records sort the data and put it on the site :) here is how to get 10 records from the database:
SELECT * FROM KK.dbo.brand WHERE brandID IN(SELECT TOP 10 brandID FROM(SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID) A ORDER BY brandID DESC) ORDER BY brandID

Ok what are we doing here?

We are first getting the top x rows witch in my case is a int called @Rows and order them with the brandID (SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID)

Second we take that info and turn it around and ask for the top 10 records so now we have the record we need but up site down (SELECT TOP 10 brandID FROM(SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID) A ORDER BY brandID DESC)

So last think to do is turn and turn all around :D and that's what we do last and then you get:
SELECT * FROM KK.dbo.brand WHERE brandID IN(SELECT TOP 10 brandID FROM(SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID) A ORDER BY brandID DESC) ORDER BY brandID

Cool aint it?
Dues anyone know if LIMIT will be in the new mssql?

Happy Netting,
Warnar

 

Please Submit when i press enter button :D

Hey all,

Got the following way from one of the old(er) blogs around here but forgot witch.
So here we go i have a Button i want to submit when someone presses Enter :D
This is the way to do it add the following code to your code behind:

Page.RegisterHiddenField("__EVENTTARGET", "The_Name_Of_The_Button");

Just replace The_Name_Of_The_Button with the name of the button :P

Edit:
One of the things also possible is that if your in a textbox and you want that someone presses enter and it will submit you can use:

TextBox1.Attributes.Add("OnKeyUp","if(event.keyCode==13) window.location.href='/gotoUrl.aspx'");

Happy netting,
Warnar

Server Error in '/' Application. Parser Error (Don't you love this :p)

Hey all,

I got a small job from www.proctrl.nl for one of there sites.
When in plementing the ASP.NET app i got the following error:

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'ExcelPriceList.price'.

Source Error:

Line 1:  <%@ Page language="c#" Codebehind="price.aspx.cs" AutoEventWireup="false" Inherits="ExcelPriceList.price" %>
Line 2:  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
Line 3:  <HTML>

Source File: d:\internet\root\www\burgerhout\www\prijzen\price.aspx    Line: 1

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

The way to make sure not to get this error is make the dir your putting the app in a virtual one :D

Happy netting,
Warnar

Get info from a Excel file using ASP.NET

Hey all,

I got a small job that has a XML file that should be displayed and i'm not in the mood of typing how i did it so here are the links i used:

http://www.c-sharpcorner.com/Code/2004/June/AccessExcelDb.asp (Mostly used the screenshot from the Excel file)
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B306572 (What to say it's the microsoft way and it works)

Hope that this may help :D

Happy Netting,

Warnar

N00B Mistake with a Component used for a Database (To mutch Database connections)

Hey all here is yet a again one of my blog about what i'm doing wrong :D

I have been bizzy with www.kapperkapper.nl as you may know. The problem is that i got error's that where like all connections to the database are open and stuff like that and i was Like WHAT!

I have a Component with all the dataset's adapters and code to use for the db on it i had my constructor witch opens the database and i had my dispose witch closes it.

A well it seemed to me that that should do the job but hey stupid me the Dispose is only called then ASP.NET thinks it is needed or what ever but not when i think it is needed.

So to fix this not i do:

using(ClientDB.Database db = new ClientDB.Database())
{
//Some stuff todo with the DB
}

Now the class is opend and disposed when the using stop's and Bug fixed :D

Happy Netting

Warnar

b.t.w. If you have any Tips for using MSSQL or related stuff me Please post them here :)

No IIS6 on Windows XP what a Big Bummer!

Hey,

I have just started installing PC for Gaming Only :D and also server for testing apps.
So me as smart as i am i ws thinking Windows XP with IIS6.

There is only one problem NO IIS 6 for XP why not????
I can't get a licence form school they don't sell Windows 2003 :(

Same question as here:  http://weblogs.asp.net/cszurgot/archive/2004/05/11/129989.aspx to microsoft why is there not IIS 6 for XP
Or is there a way??If there is please tell Thanks allready

Happy netting,

Warnar

I got a modem dumped on me! Stuppid @Slome

Hey all,

Havend been here for one reason and some more but the main was The Bloody guy at @Home!! The Dudes gave me a new modem witch awell lets say maked my connection so slow that i wanted my old modem back i went from 533kb's down and 25kb's up to 3kb's down and 6kb's up.

And Then my dad starts his letter and well where being talked to like we are some stuppid asses.

So finally  i found the problem it was my router it seems the motorola modem didn't accept the old router (WHY THE HELL DID THEY SEND ME A NEW MODEM) so i had to find a new one and i found the Tornado 242 it has wireless and 4 utp on it really cool thing but men i wish i could kick some @SLOME ASSS!!!! didn't have any workable connection for over a week.

Good luck all and @Slome one more problem and i'm a gonner!

Happy netting,
Warnar