|
Ok, Ive have read many books and seen a lot of examples of how to bind a drop down list. So I am using VS .net and I use the IDE to create as much code as I can via the GUI. My problem is that the code generated does not match the code people use in examples of binding a dropdownlist. To be honest the examples I understand, the code generated by VS I don't understand but I want to. Any help appreciated.
Here is the code. I am new to this type of programming......be gentle with me!
public class SA_ArptSelNav : System.Web.UI.Page<br />
{<br />
protected System.Web.UI.WebControls.ImageButton ZoomInButton1;<br />
protected System.Web.UI.WebControls.ImageButton ZoomOutButton1;<br />
protected System.Web.UI.WebControls.ImageButton ZoomPrevButton1;<br />
protected System.Web.UI.WebControls.ImageButton ZoomExtButton1;<br />
protected System.Web.UI.WebControls.ImageButton PanButton1;<br />
protected System.Web.UI.WebControls.ImageButton PrintButton1;<br />
protected System.Web.UI.WebControls.DropDownList DropDownList1;<br />
protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;<br />
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;<br />
protected System.Data.OleDb.OleDbCommand oleDbInsertCommand1;<br />
protected System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;<br />
protected System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;<br />
protected System.Data.OleDb.OleDbConnection oleDbConnection1;<br />
protected dbListOfAirports dbListOfAirports1;<br />
protected System.Web.UI.WebControls.ImageButton CopyButton1;<br />
protected DataView dvAirportList;<br />
protected DataTable AirportList; <br />
<br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
if (!Page.IsPostBack) <br />
{<br />
AirportList = new DataTable(); <br />
dvAirportList = new DataView(AirportList); <br />
<br />
<br />
DropDownList1.DataBind();<br />
}<br />
}<br />
<br />
#region Web Form Designer generated code<br />
override protected void OnInit(EventArgs e)<br />
{<br />
InitializeComponent();<br />
base.OnInit(e);<br />
}<br />
<br />
private void InitializeComponent()<br />
{ <br />
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();<br />
this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();<br />
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.dbListOfAirports1 = new dbListOfAirports();<br />
((System.ComponentModel.ISupportInitialize)(this.dbListOfAirports1)).BeginInit();<br />
this.DropDownList1.DataBinding += new System.EventHandler(this.Page_Load);<br />
this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;<br />
this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;<br />
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;<br />
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {<br />
new System.Data.Common.DataTableMapping("Table", "tblAirport", new System.Data.Common.DataColumnMapping[] {<br />
new System.Data.Common.DataColumnMapping("AirportCode", "AirportCode"),<br />
new System.Data.Common.DataColumnMapping("AirportID", "AirportID"),<br />
new System.Data.Common.DataColumnMapping("AirportName", "AirportName"),<br />
new System.Data.Common.DataColumnMapping("City", "City"),<br />
new System.Data.Common.DataColumnMapping("Latitude", "Latitude"),<br />
new System.Data.Common.DataColumnMapping("Longitude", "Longitude"),<br />
new System.Data.Common.DataColumnMapping("State", "State")})});<br />
this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;<br />
this.oleDbDeleteCommand1.CommandText = "DELETE FROM tblAirport WHERE (AirportID = ?)";<br />
this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_AirportID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AirportID", System.Data.DataRowVersion.Original, null));<br />
this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=0;Data Source=""D:\MGDevelopment\SIMDAC Viewer\DB\simdac_be.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";<br />
this.oleDbInsertCommand1.CommandText = "INSERT INTO tblAirport(AirportCode, AirportName, City, Latitude, Longitude, State" +<br />
") VALUES (?, ?, ?, ?, ?, ?)";<br />
this.oleDbInsertCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportCode", System.Data.OleDb.OleDbType.VarWChar, 4, "AirportCode"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportName", System.Data.OleDb.OleDbType.VarWChar, 50, "AirportName"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("City", System.Data.OleDb.OleDbType.VarWChar, 20, "City"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Latitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Latitude"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Longitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Longitude"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("State", System.Data.OleDb.OleDbType.VarWChar, 2, "State"));<br />
this.oleDbSelectCommand1.CommandText = "SELECT AirportCode, AirportID, AirportName, City, Latitude, Longitude, State FROM" +<br />
" tblAirport";<br />
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbUpdateCommand1.CommandText = "UPDATE tblAirport SET AirportCode = ?, AirportName = ?, City = ?, Latitude = ?, L" +<br />
"ongitude = ?, State = ? WHERE (AirportID = ?)";<br />
this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportCode", System.Data.OleDb.OleDbType.VarWChar, 4, "AirportCode"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportName", System.Data.OleDb.OleDbType.VarWChar, 50, "AirportName"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("City", System.Data.OleDb.OleDbType.VarWChar, 20, "City"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Latitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Latitude"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Longitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Longitude"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("State", System.Data.OleDb.OleDbType.VarWChar, 2, "State"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_AirportID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AirportID", System.Data.DataRowVersion.Original, null));<br />
this.dbListOfAirports1.DataSetName = "dbListOfAirports";<br />
this.dbListOfAirports1.Locale = new System.Globalization.CultureInfo("en-US");<br />
((System.ComponentModel.ISupportInitialize)(this.dbListOfAirports1)).EndInit();<br />
<br />
}<br />
#endregion<br />
|
|
|
|
|
Hey, I need some help to finish a project I am working on
I have a function that filters a database I loaded into a data grid it works like this:
private void selectRecordsDV()
{
string sFilter;
sFilter = String.Format("SalesDate >= #{0}# AND SalesDate <= #{1}#",xtBxStartDate.Text,txtBxEndDate.Text);
try
{
dvABC.RowFilter = sFilter;
dtGrdSales.DataSource = dvABC;
updateSalesInfoDV();
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
}
in a data view. I need it to filter one more column in the database named CustNo but can't seem to make it happen. any suggestions?
|
|
|
|
|
First of all, why the # ? Is this something I don't know about SQL ?
Secondly, what's the error ? That would help a lot in working out the problem. Is the text that's coming out in the proper format ? It should be in YYYYMMDD:HHMMSSSS, from memory.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
As far as I am aware there is no simple way of changing the position of a tooltip in C#. By default it appears that the tooltip is painted below the control in question. I would like to be able to display it to the right of mouse pointer.
Tooltip appears to be sealed. Does anyone have any examples on how to hook the dll and inject this functionality? It's probably gonna be ugly -- but I don't think I have a choice
Cheers
|
|
|
|
|
|
Hey folks,
Do you guys know how to read the names of application pools in IIS? Which API should I call?
Thanks a bunch.
|
|
|
|
|
IIS exposes much of its functionality through the iis:// directory service, which you can access using classes defined under the System.DirectoryServices namespace. Start by reading the ADSI/WMI property documentation[^] for the AppPoolId property. See Creating Applications Pools using System.DirectoryServices[^] for a sample that is close to what you require.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have built a custom component that I use rather extensively but it has a "feature" that is not correct but I haven't been able to determine why. I converted one my Delphi components and merged it with features from several contributors here. I would like to thank all of you.
The basis of the component is as follows:
using System;<br />
using System.Collections;<br />
using System.Windows.Forms;<br />
using System.ComponentModel;<br />
using System.Text.RegularExpressions;<br />
<br />
namespace MyComponents<br />
{<br />
public class myMaskedEdit : TextBox<br />
{<br />
public enum InputMaskType<br />
{ None, Dollars, Number, Integer, Percent, Phone, SSN, Zip, Custom }<br />
<br />
public myMaskedEdit()<br />
{ ... }<br />
<br />
... Other Methods ...<br />
<br />
}<br />
}
I drag the component onto my UserControl and it looks something like:
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Drawing;<br />
using System.Data;<br />
using System.Windows.Forms;<br />
<br />
namespace PARTS<br />
{<br />
public class ucRMAHeader : System.Windows.Forms.UserControl<br />
{<br />
public ucRMAHeader()<br />
{<br />
InitializeComponent();<br />
SetupForm();<br />
}<br />
<br />
... Other Methods ...<br />
<br />
#region Component Designer generated code<br />
private void InitializeComponent()<br />
{<br />
...<br />
this.myMaskedEdit1.ErrorInvalid = false;<br />
this.myMaskedEdit1.FormatText = true;<br />
this.myMaskedEdit1.Location = new System.Drawing.Point(8, 48);<br />
this.myMaskedEdit1.MaxLength = 0;<br />
this.myMaskedEdit1.Name = "myMaskedEdit1";<br />
this.myMaskedEdit1.Size = new System.Drawing.Size(108, 20);<br />
this.myMaskedEdit1.StdInputMask = MyComponents.myMaskedEdit.InputMaskType.Integer;<br />
this.myMaskedEdit1.TabIndex = 214;<br />
...<br />
}<br />
#endregion<br />
}<br />
}
I can set all the properties correctly and the program will compile and run as intended. The above code is how it is seen in the program.
I then close the window for maintaining the form. I reopen it and the StdInputMask property is now blank in the property editor. If I look at the code itself, the property is shown as it is above. But when I recompile, the property is saved as a blank and the line is removed.
While viewing the code the error message The variable 'InputMaskType' is either undeclared or was never assigned. is shown in the task list.
What I don't understand is that the enumerated type has the public attribute and it does execute as expected up until the time you reopen the form.
Can anyone identify what I missed?
Thanks.
|
|
|
|
|
I'm not sure why this question bothered someone to where they jest with their own version of it.
I guess the bottom line is that my understanding of the properties is that they are stored in the Component Designer section of the code. If I open the window again to maintain it, the Component Designer code should've repopulated the property editor...but it doesn't. Whether it is my component or not, I wouldn't think it would matter.
I don't believe my question is that far out of line.
|
|
|
|
|
hi, i've got a class which draws ball. i trigger it in window form by form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e), indicating the points by doing this:
obj.Position = new Point(e.X, e.Y);
now i wanna draw the very same image by triggering a button from another form onto form1. how should i indicate the Points?
Thanks..
Chris
|
|
|
|
|
However you like. You're not saying where you want the ball drawn. As you have no real candidate for the 'right' place to draw a ball, the three likely scenarios to me are:
1. Draw it always in the same place
2. Make a random point every time
3. Make a set of points, and iterate through them
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
i need to create a program to open and view 3d models so that they can be viewed in wire frame and shaded mode using either Direct X or OpenGL in C#
can you help me???
|
|
|
|
|
For using OpenGL with C# I recommend you to use the csGL library (is a port of the standard openGL library to C#, the best in my opinion). To use directX with C# you must use DirectX 9 which supports managed code (see MSDN).
I recommend OpenGL (csGL) and if you are a bigginer start from NeHe's homepage.
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Hi All,
I have to write a mathematics formula with lots of sin and cos fuctions. It is very inconvenient since I have to write system.math.sin/cos .
I know I can use the using keyword as followed :
using system.math to shortcut a little bit my method to math.sin/cos but it still annoying.
I know I can't but why can't I write the following
using sin = system.math.sin;<br />
using cos = system.math.cos; ???
Does anyone has an idea for a clean solution ??
thanks in advanced,
Udi Raz
|
|
|
|
|
|
Hi everybody ,
i have a problem , when i download any demo application or source codes from C# articles , windows tells me that it can't open this file(though i have installed Visual studio.net ) and asks me too choose program with which it will open it.
Whats wrong??
Regards
m0n0
|
|
|
|
|
Are you using Visual .NET 2002 or 2003 ?
Udi Raz
|
|
|
|
|
|
hi all,
I hope any one can help me :
what is the classes in C# or API functions allow me to do uninstall my program from PC??
thanks.
|
|
|
|
|
There aren't any.
You'll find the command line to uninstall an application in the registry in a key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall. The uninstall information is in a value named 'UninstallString'. Pass that to System.Diagnostics.Process.Start.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
How can I browse through local shell folders such as the desktop and 'my computer' inside a treeview?
I have tried using SpecialFolders, but It only points me to the file folder compatable to the special folder, which does not contain all I need (e.g. the Desktop doesn't contain My Computer, and My Computer doesn't exist).
I want something like in the windows explorer - like the FolderBrowserDialog but not in a new window but inside a treeview, so I can handle this information on my own.
Thanks!
|
|
|
|
|
|
Thank you!
|
|
|
|
|
i am new in c# and i am having a problem in getting primary key value from table to a int variable
example
select user_id from user where login="dcds" ;
i need to store the user_id of this guy in a variable so i can use it for future so any one can tell me how to do this in asp.net using c#
thanks
|
|
|
|
|
This is a long process .... I haven't worked with asp.net in a while but I am sure it is similar to this ...
make sure to specify using System.Data and using System.Data.SqlClient
SqlConnection connection = new SqlConnection(YOUR_SQL_CONNECTION_STRING);
/*
//EXAMPLE CONN STRING
workstation id=YOUR_MACHINE;packet size=4096;integrated security=SSPI;data source="YOUR_SQL_SERVER";persist security info=True;initial catalog=YOUR_DB
*/
connection.Open();
SqlCommand command = new SqlCommand("select user_id from user where login='dcds'");
command.Connection = connection;
SqlDataReader reader = command.ExecuteReader();
int Id = -1;
while(reader.HasRows)
{
reader.Read();
Object obj = reader["user_id"];
if(obj != null)
Id = Convert.ToInt32(obj);
}
Hope this helps ....
Shardool Karnik
Lead Software Engineer
Compass Technologies, Inc.
http://www.compasstec.com
|
|
|
|
|