Hashtable ht = (Hashtable)Session["ht"]; i am using hashtable for storing values which i need to append to some query i have a function which has Hashtable ht = (Hashtable)Session["ht"]; ht.Remove(HName.Value); this function gets executed on a postback click event of a button control as well as on another button control which is needed as per my flow and i get teh error but without any postback if i go on stroing values then i dont get how do i overcome this used is it possible to replace the existing key??
The above error occurs when you try to insert a key that already exists and since sessions are available in postback and also partial postback your old values are retained in session hence I would suggest check whether key exists and if it does not then insert
ya u r ight the key exists
so i get the error , but how do i update or replace it
any sample example
and whts the major difference between normal array & hashtable in terms of working & speed & any other property in dotnet
if (ht.ContainsKey(HName.Value)) { ht[HName.Value] = "new value"; }
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.