Do something like this: dropdownlist.Items.Add(new ListItem("--Select Item--")); dropdownlist.AppendDataBoundItems = true; dropdownlist.datasource = somedatasource; dropdownlist.TextField = "Something"; dropdownlist.ValueField = "somefield"; dropdownlist.DataBind(); Thats all you have to do. Add an item in the list and then set AppendDataBoundItems = true before you bind the list to a data source.
guroo13
Posts
-
Drop Down List -
create a webforn in runtimeOne Idea!!! How bout if you use XML and XSLT Create xml after reading the tables in database you might be bulding forms upon and then convert xml by using xslt? If not depending on tables on database just make some rules to create xml which will represent a form and then convert that through xslt? What do you think?
-
Combo box Event catchingIf you want to catch the event inside the user control itself, that will not be a problem. For that you can double click on the combobox while in design mode and enviorment will auto generate the handler for the SelectedIndexChanged event by default in side the code behind for .ascx file. But don't forget to set the "AutoPostBack" property of the dropdownbox to true. If you want to handle SelectedIndexChanted even inside your page where you are using this user control then the quickest souloution is as follows: Create a public property in your user control like: public DropDownList List { return ddlYourTargetComboBox; } on your page do something like: ucYourUserControlInstance.List.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged); void list_SelectedIndexChanged(object sender, EventArgs e) { //Implement logic here } Hope this helps
-
RSACryptoServiceProviderHi, I am trying to use RSACryptoServiceProvider in my ASP.NET application to access keys from a MachineKeyStore on my computer, running windows xp and IIS 5. I created machinekeystore like following in Visual Studio 2005 Command Prompt: aspnet_regiis -pc "CustomKeys" -exp (command was successful) Then I executed following command because I am impersonating my web application with a non-default user: aspnet_regiis -pa "CustomKeys" "domain\auserforapplication" (command was successful) Then I worte the following code:
public partial class Examples_EncryptionExample : System.Web.UI.Page { CspParameters CspParam; string publicXmlString = string.Empty; string privateXmlString = string.Empty; protected void Page_Load(object sender, EventArgs e) { try { byte [] encrypted; string decrypted; UnicodeEncoding ByteConverter = new UnicodeEncoding(); encrypted = EncrptData("data to encrypt"); Response.Write(System.Text.Encoding.Unicode.GetString(encrypted)); decrypted = DecryptData(encrypted); Response.Write(decrypted); } catch (Exception ex) { } } public string DecryptData(byte [] data) { RSACryptoServiceProvider RsaCsp; byte[] decryptedData; RsaCsp = new RSACryptoServiceProvider(); RsaCsp.FromXmlString(privateXmlString); decryptedData = RsaCsp.Decrypt(data, false); return System.Text.Encoding.Unicode.GetString(decryptedData); } public byte [] EncrptData(string data) { RSACryptoServiceProvider RsaCsp; RSACryptoServiceProvider RsaCsp2; UnicodeEncoding ByteConverter = new UnicodeEncoding(); CspParam = new CspParameters(); CspParam.KeyContainerName = "CustomKeys"; CspParam.Flags = CspProviderFlags.UseMachineKeyStore; byte[] encryptedData = ByteConverter.GetBytes(data); RsaCsp = new RSACryptoServiceProvider(CspParam); //Getting public key publicXmlString = RsaCsp.ToXmlString(false); //Getting private key privateXmlString = RsaCsp.ToXmlString(true); RsaCsp2 = new RSACryptoServiceProvider(); RsaCsp2.FromXmlString(publicXmlString); encryptedData = RsaCsp2.Encrypt(System.Text.Encoding.Unicode.GetBytes(data), false); return encryptedData; } }
The problem over here is that when ever I try t -
Enterprise Library 2.0sorry, I copied and pasted the following b4: type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/d:SANDBOX,DEBUG" /> in the last line in codedom tag its /d:TRACE
-
Enterprise Library 2.0 (Database Listener) [modified]Hello, I am developing a web app and trying to use Enterprise Library 2.0. I am using it for logging for now. I achived the logging on a flat file but when I tried to start doing the logging by using a DataBase Listener. I failed. Here's how I am using it after including all possible references to my web app. I configured a datasource with following attributes setup: -Server (my server name) -Database (my database in my server) -Integrated Security (I used API.. something, false, true and I even tested after removing this tag aswell). -user (my user name) -pwd (my password) Then I configured a Database Listner and gave the reference of my datasource. Then I configured a Logging block by adding different categories and then I added reference to my Database listner in categories. I also tested by adding and removing following in web.config: system.codedom compilers compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/d:TRACE" compilers system.codedom ---------------- After doing this all when I try to log an entry after specifing the category to the entry and other required attributes. NOTHING HAPPENS in tables I generated after running the script file provided by Best Patterns and Practices team. I couldnt log any data. Is there anybody who can help me or tell me what I am doing wrong? Thanks in Advance -- modified at 21:13 Tuesday 25th July, 2006
-
Enterprise Library 2.0Hello, I am developing a web app and trying to use Enterprise Library 2.0. I am using it for logging for now. I achived the logging on a flat file but when I tried to start doing the logging by using a DataBase Listener. I failed. Here's how I am using it after including all possible references to my web app. I configured a datasource with following attributes setup: -Server (my server name) -Database (my database in my server) -Integrated Security (I used API.. something, false, true and I even tested after removing this tag aswell). -user (my user name) -pwd (my password) Then I configured a Database Listner and gave the reference of my datasource. Then I configured a Logging block by adding different categories and then I added reference to my Database listner in categories. I also tested by adding and removing following in web.config: ---------------- After doing this all when I try to log an entry after specifing the category to the entry and other required attributes. NOTHING HAPPENS in tables I generated after running the script file provided by Best Patterns and Practices team. I couldnt log any data. Is there anybody who can help me or tell me what I am doing wrong?
-
Reflection with static inherited methodsThanks alot Guffa for answering!! seems like I am out of luck :(
-
Reflection with static inherited methodsHi Josh, I really appriciate that you answered my question. I tried by taking off DeclaredOnly BindingFlag but it still didnt work. Any other suggestion? By the way, I was able to see the methods declared public in parent class, but I was not able to see the public static method declared in parent class. Thank you
-
Extract Relationship from MS SQLHi Exprets, I am making an application using MS SQL Server and I need to know that what kind of relationships are existing between table e.g. 1-1 or 1-M. I can get the constraint's, coulumn, table, types information from INFORMATION_SCHEMA at this point but I still need to find the relationship types between tables. I am using C# and ADO.NET and the version of Database Server right now is MS SQL Server 2000 but Finally I will be utilizing MS SQL Server 2005. Any idea, suggestion, snippet? Thankx
-
rootCR.cerHello Experts, I want to read .cer file generated by RootCA. I want to encrypt scramble it with some garbage data and make .cer file unsuable, then I want to remove the garbage data from .cer file so it could be useful again. I wanna do it because if I give anybody a .cer file to install it on some machine, he should not be able to steal it. The only way this .cer file could be installed in Authority Store is by my program which gets the confirmation before removing the garbage data from a webservice and sends that webservice client's IP and username. I tried opening the file in C and C++ both couldnt read the file. Can I do it in VC++?. If I can then how? Thanks Alot in Advance
-
rootCS.cerHello Experts, I want to read .cer file generated by RootCA. I want to encrypt scramble it with some garbage data and make .cer file unsuable, then I want to remove the garbage data from .cer file so it could be useful again. I wanna do it because if I give anybody a .cer file to install it on some machine, he should not be able to steal it. The only way this .cer file could be installed in Authority Store is by my program which gets the confirmation before removing the garbage data from a webservice and sends that webservice client's IP and username. I tried opening the file in C and C++ both couldnt read the file. Can I do it in C#. If I can then how? Thanks Alot in Advance