I think it would be easier for you to understand my problem if I explain the scenario a bit.
What I am doing is developing a system to a doctor using asp.net c#. For the creation of the prescription, I add a check box list for the list of medicines and submit button below it. When the submit button clicked selected check box list items added to the sql server database and show a data grid with the selected medicines in the same page.
In the data grid there are two columns for medicine name and dosage.Medicine name is taken from the database.I need to give the user the ability to enter the dosage through that grid view. I need to use update command because the record is already there in the sql server.But empty value in the dosage column.I tried to use update command in the data source control. But I can't figure out how to give the WHERE clause because I can't specify the database row which the updating record relate to.
I would be glad to hear some help from you. All the comments are welcome.
You need to set a parameter(s), please check this example to understand how it works. I guess, that you've added in the database some column that is unique identifier.. some autoincrement int or guid.
Related
I have a table named "Rezervare" with the field id, id_hotel, data_inceput, data_sfarsit, pret.
My task is to display all the records without using databound controllers . Afterwards I need to update and delete them so I need to select specific id's to do those operations.
Since I am new to C# and ASP I don't know how to display and make buttons that would take the right id on press in order to delete or update a record in the table.
To sum things up I have 2 questions:
How do I display the data in the table without using listview,detailsview,formview etc.?
How do I make buttons for each of the item that on press take the right id(just like in listview would)?
(I don't know the answer to the 1st question so that answer might just answer my 2nd)
I have currently implemented a drop-down which displays all the products name from database. On selection of product name from drop down my edit product form will get populated and user can update selected record successfully.
Now my problem is that i have 5000 products in my database.In this case its very difficult for end user to select particular product in drop-down and also populating drop down with large number of records server side takes more time.
What approach should i use to make selection user friendly.Any ideas or help is greatly appreciated
Thanks!!!!
You should use an editable combo box with auto complete feature and load the data depending on user input. Refer this: http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/ComboBox/ComboBox.aspx
This way you dont need to worry about the amount of data, it gets filtered as the user inputs some string.
How do I create a gridview with an empty column to allow user to enter a value which will then be used with the rest of the columns to update a table. I was hoping to allow user to go down a gridview change a number of values and upon button push have the new table displayed to review changes before submitting to a database. The gridview is dynamically bound from an ilist which makes it difficult as the page lifecycle disables me pulling the items out using .findcontrol. And Neither can I use viewstate("newtable") = ilist method as this will not account for the editable field. Help!!!
J
Firstly, your question is not clear if you put your code sample it will be more. if you work with entity framework for database op., datagridview already allow updates. yourentityobject.SaveChanges() is enough.
I have a gridview displaying data by using an Obejct Data Source which is then connected to a Business Layer.
The data shown/retrieved is from two tables with a join.
Is it possible to have a custom update method which, when the user clicks edit against the row, it will update only the one table out of the two that's required for the data shown (however if it can update the entire record that's fine too)? If yes how do i tie the ODS, along with my BL? Any info would be appreciated as my research so far has not given any examples of this.
To give an example one table is a user and the other table is results. The Results table is connected to the Users table by a UserID (foreign key) but the gridview shows a little more info when both tables are joined.
You can place a linkbutton inside a template field & give it CommandName="MyUpdate". You can then check for the commandName on rowCommand event of gridview & handle your custom update there.
if(e.CommandName =="MyUpdate")
{
// Perform your update
}
I'm trying to create an ASP.NET/C# page that allows the user to edit a table of data, add rows to it, and save the data back to the database. For the table of data, I'm using a DataGrid whose cells contain TextBoxes or CheckBoxes. I have a button for adding rows (which works) and a button for saving the data. However, I'm quite stuck on two things:
The TextBoxes and CheckBoxes should retain their values on postback. So if the user edits a TextBox and clicks the button to add more rows, the edits should be retained when the page reloads. However, the edits should not be saved to the database at this point.
When the user clicks the save button, or anytime before, the DataTable underlying the DataGrid needs to be updated with the values of the TextBoxes and CheckBoxes so that the DataTable can be sent to the database. I have a method that does this, but I can't figure out when to call it.
Any help getting this to work, or suggestions of alternative user interfaces that would behave similarly, would be appreciated.
Take a look at the ASP.NET GridView control. It's newer than the DataGrid and has editing features, editing events, etc built in.
Check out the following website:
http://highoncoding.com/Categories/7_GridView_Control.aspx
There are tons of articles on the above link about the GridView control.