.net-2.0

Databinding DropDown Control in .Net

故事扮演 提交于 2019-12-11 08:18:01
问题 I am binding the dropdown with db entity. ddlCustomer.DataSource = Customer.GetAll(); ddlCustomer.DataTextField = "CustomerName"; ddlCustomer.DataBind(); I want to add "SELECT" as the first itemlist in dropdown and bind then entity to the dropdown. How can i do this? 回答1: Add: ddlCustomer.Items.Insert(0, "SELECT"); After ddlCustomer.DataBind(); The item must be inserted after the data bind because the data bind clears the items. 回答2: I don't know if there is a one line solution to this, but

How to get UUID generated by MySQL into a C# variable

一曲冷凌霜 提交于 2019-12-11 08:17:19
问题 Here is the query: string query = @"INSERT INTO session (PK_Id, user_id, login_time, machine_ip, machine_fingerprint) VALUES (UUID(), @UId, @LogInTime, @MIp, @MFingerPrint); "; Now I need this last inserted id back, which is a UUID generated by MySQL. As far as I read there is no select_last_insert_id() function for UUIDs!! And I read for php you could assign UUID() function first to a variable and then return that value. But how to go about that in C#? Something like this, but not exactly:

How to get the list of SqlInstances of a particular machine

亡梦爱人 提交于 2019-12-11 06:55:33
问题 Can anyone tell me how to get remote Sqlserver instances using c# and SMO or any api? I have a remote server name "RemoteMC", which has 2 instances of sql server: "RemoteMc" and "RemoteMC\sqlexpress" I try to get the instances in code like this: Server srv=new Server("RemoteMC"); DataTable dt=SmoApplication.EnumAvailableSqlServer(true); But it returns "Host\sqlexpress" I don't know what went wrong. How can I get the result back as: RemoteMC RemoteMC\sqlexpress; ? 回答1: The SmoApplication

Wait window in a windows application

帅比萌擦擦* 提交于 2019-12-11 06:16:52
问题 I basically need to show a wait window to the user. For this i have put two seperate window forms in the application. the first form is the main form with a button. The second one is a empty one with just a label text. On click of the button in Form1 i do the below Form2 f = new Form2(); f.Show(); Thread.Sleep(2000); f.Close(); My idea here is to show the wait window to the user for 2 second. But when i do this the Form 2 is not completely loaded because of which the label in it is blank.

Mantain a control position fixed when scrolling a panel

帅比萌擦擦* 提交于 2019-12-11 04:48:11
问题 I have a label label1 in the middle left of a large custom panel panel2 that is scrolled in a parent panel panel1 . alt text http://lh4.ggpht.com/_1TPOP7DzY1E/SzNN2g9Sv4I/AAAAAAAAC1U/A_LlLOoejX8/s800/formScroll.png I would keep the label1 always in the visible left middle of the panel2, even when scrolling. In the real example, my panel is a user control that generates the some labels in its left side. The panel scrolls, but I need to keep the labels always visible. How could it be achieved?

VB.NET 2012 Property Set on Property Get

让人想犯罪 __ 提交于 2019-12-11 04:37:57
问题 I am having a very weird situation in VS 2012 RC VB.NET project targeting .NET 2.0. For some reason the property's Set method is called in addition to its Get method: This works as expected: Dim _searchparray = New Byte() {37, 115, ...} Dim rep() As Byte = _opt.ReplaceBytes If Arrays.CompareTo(rep, _searchparray, 1, False) = -1 AndAlso _opt.SearchMatchPlaceholderInReplaceBytes Then ... That is _opt.ReplaceBytes's Get method is called only once, and it's Set method is not called. But this does

ASP.NET with jQueryUI: text box value is getting as null in Button click event

≯℡__Kan透↙ 提交于 2019-12-11 04:33:49
问题 I have an ASP.NET page where I have a button When a user clicks on the button,I will check whether the user has logged in or not.If not logged in I will show a modal popup to login (using jQueryUI). I have placed one textbox(txtPassword) and one button(btnLogin) control in the Div which will be shown by the jQueryDialog.But in btnLogin's Click event, I am not able to read the Text value entered in the textbox txtPassword The below is my code <form id="form1" runat="server"> <div> <br /> <asp

Handling exceptions vs. Preventing them from occuring in the first place - C#

﹥>﹥吖頭↗ 提交于 2019-12-11 04:33:21
问题 I have a asp:BoundColumn with DateTime? data (i'll call it column X) in the asp:GridView. I loop through all the rows in the grid, and cast the .Text property to column X to DateTime (i need this to do some checking and change the cell background color if needed). I have 2 options: wrap the cast in try/catch ... handle FormatException (in case column X gets rendered with some junk in it) ... and work only with valid DateTime values. check the column X to make sure it's in the correct format

Programming pattern using typed datasets in VS 2008

a 夏天 提交于 2019-12-11 04:29:19
问题 I'm currently doing the following to use typed datasets in vs2008: Right click on "app_code" add new dataset, name it tableDS. Open tableDS, right click, add "table adapter" In the wizard, choose a pre defined connection string, "use SQL statements" select * from tablename and next + next to finish. (I generate one table adapter for each table in my DB) In my code I do the following to get a row of data when I only need one: cpcDS.tbl_cpcRow tr = (cpcDS.tbl_cpcRow)(new cpcDSTableAdapters.tbl

Horizontal Table With DataList And DIVs?

谁说我不能喝 提交于 2019-12-11 04:23:16
问题 I'm trying to create a table layout with headers on the left and horizontally aligned fields. (See mock-up below.) I'm trying to accomplish this using a DataList -- stuck with .NET 2.0 -- and wrapped in a div with a scrollbar on the x-axis so that if enough groups are visible, a scroll bar will appear. Group One Group Two Group Three Header One Value Value Value Header Two Value Value Value Header Three Value Value Value I'm struggling with two points, both seen in the below code and jsFiddle