I've a SQL DB with various tables that save info about a product (it's for an online shop) and I'm coding in C#. There are options associated with a given product and as mentioned the info recorded about these options is spread across a few tables when saved.Now when I come to edit this product in the CMS I see a list of the existing product options and I can add to that list or delete from it, as you'd expect. When I save the product I need to check if the record already exists and if so update it, if not then save a new record. I'm trying to find an efficient way of doing this. It's very important that I maintain the ID's associated with the product options so clearing them all out each time and re-saving them isn't viable unfortunately.To describe again, possibly more clearly: Imagine I have a collection of options when I load the product, this is loaded into memory and added to / deleted from depending on what the user chooses. When they click 'Save' I need to check what options are updates and what ones are new to the list.
I'm trying to error handle a registration aspx/c# page on my application and want to run a check whether the email address that a user has tried to register already exists as the email address is used as a primary key in my database.
I have tried IF NOT EXISTS/IF EXISTS but these dont give the desired effect so was wondering if there was another way around it?
I have a ASP.Net website with links to files stored on a file server. These files are modified constantly and so the links will not always be valid, this includes changes to permissions, files being moved or deleted, etc. I implemented a method in the code-behind to check the validity of these links as they are constructed, if it fails the code will add CSS to change the color of link:
Check URL
/// <summary> /// Check if a URL exists. Method by http://www.vcskicks.com/check-website.php /// </summary> /// <param name="url">URL to validate</param> /// <returns>True if the URL was resolved, false otherwise</returns>
[Code]....
My problem is that not all the invalid links are getting the style added to them. The strange thing is that when I step through the method in debug mode using one of the bad links that was not colored, the method will return false and color the link as expected. There's a lot more involved then what I present above, but I searched the entire aspx code-behind for any other locations where the link url is being set and couldn't find any. I don't know if there's some post processing going on that somehow clears any styles that were applied to some of the links. The fact that some links are colored while others are not is very confusing to me. Has anyone else encountered similar behavior before?
I use a ItemDataBound for a repeater.But i use 2 kinds of linq querys to bind it.Some of them has a MerkID, and some doesnt have this item.So its easy i need to do this:
if(e.Item.DataItem.Contains("MerkID"))
{ //Code for linq query 1
} [code]...
So of course the if selection doesnt work, but how can i do that? I already tryed this:
DataRowView drv = (DataRowView)e.Item.DataItem; if (drv.Row.Table.Columns.Contains("MerkID"))
But that doenst work because he cant convert it to a datarowview because its a linq class.So what to do? Right now i use a try and catch, but there are better solutions i guess...
according below thread I change file name when users upload from file upload control:
[URL]
below is my code that I changed if(this.fuppdf.HasFile) { string path = Server.MapPath(".") + "../image/House/article/pdf";
[Code]....
if file name be duplicate it add 1 at the first of file name but here it doesn't work I mean when I upload file i.e catalog.pdf ("catalog is the text in txttitle) it saves in the host with this name catalog.pdf
but when again I want upload catalog.pdf in host it overwrite last (catalog.pdf) but I want if there was catalog.pdf file it saves with this name 1catalog.pdf in host
I have a grideview and 2 buttons. I need to only show the buttons when the gridview has a selected item. My code looks like this:
protected void Page_Load(object sender, EventArgs e) { btactivate.Visible = false; btdeactivate.Visible = false; //Show Activate and Deactivate Buttons only if an item in the gridview is selected if (GridView1.SelectedIndex != -1) { btactivate.Visible = true; btdeactivate.Visible = true; } else { btactivate.Visible = false; btdeactivate.Visible = false; } }
But the problem I have now is that only when I select the second time a item in the gridview the buttons show up. I need to have the the buttons show when I select the first time. I have tried changing the selected index to "-0" but that shows the buttons all the time (even when I dont have something selected).
I am trying to show the user of my application that when they click on a menu item that their selection gets shown by changing the background color of that menu item
I am using the default menu that comes with asp and is contained in the site master. the default CSS for the menu has a hover and active properties but only the hover works.
I am having 2 list box in my form. I am adding some values from 1st list box to 2nd one. What i need is i would like to save the data in the list box in sql table.
I would like to check whether a folder exists or not if not create. I'm sure this folder exists, but for some reason I get "false" when I check with "Exists" method.
The only reason I think could be because of the W: drive? I moved this application to production site and even there it returns false.
while I'm type in Windows explorer on my localhost and on the server "W:/Webs/ASPPages/cropper/uploads" it opens this folder. So my localhost and IIS server has W: mapping.
for test I tried to create the folder then it says can't find the path...
userFolderName = @"W:/Webs/ASPPages/cropper/uploads" //I also tried @"W:WebsASPPagescropperuploads" //I also tried @"W:WebsASPPagescropperuploads" //I also tried "W:\Webs\ASPPages\cropper\uploads" DirectoryInfo dirInfo = new DirectoryInfo(userFolderName);........
I am saving grid data. Grid contains one textbox in item template column. But it was not saving any data, which was entered in textbox(Just saving 'NULL'). There was not error while debugging. Below is code i am using.
Wat i did is in the first header of gridview dropdownlist i have binded the PO Item , so that user can select item n make invoice...
Here the problem is user will click addnewrow button to create new row second row , again user is able to select the same item what he selected in first row of gridview. here how to avoid duplication in the second row .
Say i have four PO item
Item1,Item2,Item3,item4
user may select Item1 in first row , after clicking addnewrow button user will get second row
here again user is able to select Item1 from dropdownlist ... how to avoid duplicate selection
coz the dropdownlist is binded from database using sqldatasource n filter based on user selected PO no.
Duplicate Item selection should be removed until all the four item is selected ...
I am using aspnet menu control and i want to hide the item initially on page load and show the item after an event is trigger say button lick event Can any one give me an example?
I have a list with 2 sorts of items. Items that have actual values (1,2,3,4 etc) and items that are like group headings so all their values are set to 0. If someone decides to select a group heading - which has a value of 0, is it possible to redirect them to my 'Select an item' item which has a value of ""?
If worse comes to worse, I can just reconstruct the entire list, although if possible I'd like to avoid it.
I have a project that queries a set of times from a database and uses these entries to populate a dropdownlist. Once the page is loaded, the user can select one of the items in the DropDownList. When the "Save" button is clicked, the Selected item value is returned to the [HttpPost] version of the controller action. This item is then stored into session. If the system returns to the page containing the dropdown, I want the saved Value to be selected in the DropDownList. What actually happens is that the DropDownList is always set to be the first item in the list.
Database Table: This data has been imported using Link to SQL
Error 1 'System.Data.OleDb.OleDbDataReader' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.OleDb.OleDbDataReader' could be found (are you missing a using directive or an assembly reference?)
public partial class Default2 : System.Web.UI.Page { System.Data.OleDb.OleDbConnection Con = new System.Data.OleDb.OleDbConnection(System.Web.Configuration.WebConfigurationManager. ConnectionStrings("MyConnectionString").ConnectionString); protected void Page_Load(object sender, EventArgs e)
Here when i click on button it insert all data into table but it didn't insert my selected item from dropdownlist it insert select city that i define in page_load
DDL1.Items.Insert(0, new ListItem("select city", "0"));
And when i delete this code from page load it insert in table first row of my table it didn't insert my selected item from dropdown list.
I am trying to get a drop down and a form view to work together. I've never used form views before. I also am using the entity framework to do everything. This is also my first time with it.
I want to be able to have a drop down, that is populate from the same data source as the form view. So far that works fine.
I then want to be able to change the drop down item, and it change the form view item that is displayed. I cannot figure out how to make this work.
here the method OnItemDataBound , look at how it work
[Code]....
problem is the e.Item always get one and only one last item . turn out my listview display many rows but with a consistent content of the last user (in the database record) . How can i resolve this ?? any creative method are accepted , i'm just want to finish this project
What I need is if I select default item i.e. 0 in Zone dropdown I need to show all items in store dropdown. Below is my stored procedure to get the stores
ALTER procedure [dbo].[selectcenter] @RegionID varchar(5) as begin select ID,Centername from Shoppingcenter where RegionID=@RegionID group by ID,Centername end