C# - Ninja Technique To Update A Whole Lotta Of Values From Repeater To Database?
Feb 12, 2011
I have a repeater with about 100 rows, and 4 columns in each row. something like this table:
Username HasIpod HasGymMembership HasCar
``````````````````````````````````````````````````````````````
User1 chcekbox checkbox checkbox
User2 chcekbox checkbox checkbox
User3 chcekbox checkbox checkbox
User4 chcekbox checkbox checkbox
well, you get the idea.The admin can tick/untick any box anytime and click on a "Save" button at the end of page and thats when I need to update the database. I need to add a row in one of the table if a certain checkbox is checked, delete it if its unchecked.I can just loop through the repeater and VERY EASILY do it with each row. but my concern is that, at the worst case, this will use about 100 rows X 3 = 300 database accesses. Thats bad right?I thought of concatenating all values into a form of csv.. something like:user1id,1,0,1;user1id,0,1,1just a list of userid, its values separated with , and the next user's values separated with ; and in the database I can just use a split function and a bunch of while loop and update accordingly.but It just doesnt satisfy me for some reason. Is there a better way to deal with a such a situation? I am sure this is not a unique case, what do you guys do in a scenario?
View 4 Replies
Similar Messages:
May 5, 2012
Here is my .aspx page
<asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <tr bgcolor="maroon"> <th>
Subject Id </th> <th>
Subject Name </th> <th>
Obtained Marks </th> </tr>
</HeaderTemplate> <ItemTemplate>
[Code] .....
c# - code behind
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
this.PopulateRepeater();
} } private void PopulateRepeater() {
[Code] .....
Current repeater looks as...
Subject_Id Subject_Name Marks
s1(lable) subject1(lable) 56(textbox)
> Now, I want to make Updation with repeater (in same application).
I want to update Marks(into textboxes only, sub_id and name fatched from database dynamically) in each row of repeater.... how is it possible ??
View 1 Replies
Jun 7, 2010
Just dipping my toe with doing simple VB.NET stuff. Have used classic ASP, so im used to being able to place any field from a recordset whereever i want to putit , and i have just tried to recreate this event.Its got me a bit lost.. now i have read up and understand why it doesnt work - cant use DataItem in a HeaderTemplate - i get that, but how would you do something where you have complete control of the way the table is being set up? and you can use the contents of the container whereever you want, however you want?I just want to be able to get the values from database table, and put them into an html table, in a specific way.
[Code]....
[Code]....
View 6 Replies
May 7, 2015
I am displaying data in html table using Repeater. And I have two button for each row. When I click 1st button I want to insert particular row and using second button the same row to be updated. But my prob is When i click button all row is inserting. And I am using Button click event for two button.
View 1 Replies
Jan 18, 2010
I need to utilize about 30 different database values from within a repeater ItemDataBound Event and I am wondering if there is a better way to do it. I am currently exposing them by doing something like this 30 times:
[Code]....
Rather than making 30 declarations, is there a way I can make them all available as short variable names? The variable name could be the same as the field name.
View 4 Replies
Apr 12, 2010
I have a typical gridview/formview master control setup. When I try to update or insert I don't get any errors but it also doesn't work. When I try to insert data all I get are null values and when I update, none of the values are updated. The formview looks like its working, but just doesn't. The primary key is an identity and it auto-increments by one.
[Code]....
View 3 Replies
Jun 6, 2010
User enters values into text boxes (personal information etc.) and then presses a save changes button. The values in these text boxes get stored in an SQL database. The problem I have is that when updating the database using the values from the text boxes, the page refreshes and the values in the text boxes are lost (or rather they return to the values that are already in the database as the data from the database is loaded into the text boxes on Page_Load). When I update the database using valuse stored in variables it all works fine. What is the best way to update with the values from the text boxes?
View 2 Replies
Jan 21, 2010
my database does not update when i pass edited values from textboxes, which is kind of weird. I even try using vb class file to receive the values. but it just never do so.
View 5 Replies
Nov 23, 2010
I have a gridview in a page, and some Texboxes along with a button(for issuing a command) in the same page. The TextBoxs were inputted values and the values could be assigned to the selected row of the gridview, some fields are the same values along the rows, and the values are inputted in the TextBoxes for using several times without change.
Well, I need to know: how can I assign the values of the TextBoxes to the selected row of the gridview. in another words, how can I access the cell members of the gridview when it is in edit mode? (Q1)
If the row is not selected, I have no way to know which row should be assigned values, since there is no such things like "current row".
So, if the selecting button(or link) of the gridview is not selected, the button along with the TextBoxes should keep disabled, until a row's "Edit" button is clicked. (Q2: How can I find if the Edit button is clicked? I guess I can use the property "mode" of the gridview to indicate the situation. )
And the last question is (Q3), how can I ensure the values are updated to the database? Maybe I dont need to do more things than just click the uppdate button of the row of the gridview.
View 2 Replies
Feb 24, 2011
I have take a datagrid view and now i want to update the records as the database is been normalized i need to enter the multiple rows at once. How you I convert the datagrid to enter the data so that it would be easy for me to update the records?
View 1 Replies
Jul 28, 2010
I'm coding my first VB web application, which allows a user to input an order number and pull up invoice and shipping data linkd to that order number.
I have the first bit down and working, where the existing data in the database is displayed in the GridViews. One of the GridViews is set up to allow data editing, and I have syntax set to make the row editable, but I'm struggling with getting the "Update" link/functionality to work. I want to assign the values in each cell to an object (ie. 'dgInvNumber' for Invoice Number), but everything I've tried (been doing a ton of Google searching for help, but no luck yet) keeps giving me an "Object reference not set
to an instance of an object" error when I click the Update link for the row of data being edited.
At this point, I don't know what syntax to use to get the edited values out of the GridView row and assigned to objects for each cell (I have a total of 10 cells that can be edited in a row).
For background info, the GridView is set up with Bound Fields. I'm using Visual Studio 2005. Alot of places I've looked talk about TextBox controls and using FindControl. Also seen some places talk about DataBoundLiteral Controls. I tried the latter with no luck (still getting error). For TextBox controls, I don't understand how to use that part, since it mentions referencing the TextBox controls declared in the EditItemTemplates of the TemplateField column fields in the GridView control. But I didn't set up anything in the EditItemTemplates (that I know of).
View 1 Replies
Apr 2, 2010
I have a repeater that I have bound to a sql reader via my code behind page.
However I can't figure out how to populate the controls in my repeater in my code behind code.
At the moment I am having to specify the database field e.g productprice with the control in the .aspx page like this
<asp:Label ID="LabelUnitPrice" runat="server" Text='<%# Eval("productprice") %>'></asp:Label>
I would rather specify fields in my code behind than embedding them in the .aspx page.
I also have a subtotal label control in my repeater that I would like to populate its text property by mutiplying two of the database values e.g productprice * unitprice shown in my repeater.
I need to do this in code behind, looping through the repeater. Any idea of how I can do this in C#?
View 3 Replies
Jan 28, 2011
This code works fine if i use this inside ssercontrol > panel and i have a checkboxes in table when no checkbox is checked its works fine .... but if i disabled and checked any of the textbox then this doesn't work .... in usercontrol why ? i didnt understand ..
<script type="text/javascript" language="javascript">
function checkboxChecked(){
var allInputs = document.getElementsByTagName("input");
for(var i=0; i<allInputs.length; i++) {
var chk = allInputs[i];
if(chk.type == "checkbox" && !chk.disabled && chk.checked) {
return true;
}
}
alert("OOps! You haven't selected all available checkboxes");
return false;
}
</script>
View 4 Replies
Jan 3, 2010
I heard that DataReader works on forward only readonly fashion and at a time it willread a single record.Suppose when i execute the below code
SqlDataReader reader=cmd.ExecuteReader();
gv1.DataSource=reader;
gv.DataBind();
How the does the gridview populate all records?.As the reader is capable of reading one row per read,I thought only the last row is available for GridView to display.
View 3 Replies
Apr 20, 2010
Nifty and free asp.net controls that replicate the following databinding technique? [URL]
View 11 Replies
Aug 17, 2010
I would like to secure any URL below the http://MyServer/Admins and limit it to a specific role.
In webforms it was straight forward. I just put a child web.config in the /Admin/ folder and add <authorization> <allow roles> tags to it.
How would be the equivalent technique in MVC?
View 5 Replies
Jan 4, 2010
I've figured out how to use a repeater field, now what I want to achieve is a "total" figure for the column, and this figure needs to appear the footer.
Back in ASP 3.0, I would simply create a variable, and on every step as I looped through the recordset, I would add the current to the variable, including its original value. At the end, I'd have the total. Apparently I can't figure out how to do the same thing in ASP.NET.
This is what I'm doing (which doesn't work):
[code]....
View 4 Replies
May 7, 2015
i showed two column (Electronics,Photoshop) but i have six. i want to update their checked or unchecked condition in database (0,1) how do i do?
<asp:CheckBox ID="CheckBox1" runat="server" Text="Electronics" />
<asp:CheckBox ID="CheckBox2" runat="server" Text="Photoshop" />
<asp:CheckBox ID="CheckBox3" runat="server" Text="VideoEditing" />
<asp:CheckBox ID="CheckBox4" runat="server" Text="Gaming" />
<asp:CheckBox ID="CheckBox5" runat="server" Text="Coding" />
<asp:CheckBox ID="CheckBox6" runat="server" Text="Miscellaneous" />
View 1 Replies
Oct 1, 2010
i have table contain two column id and word .word column may contain one word or two or three ex ( computer , computer software , computer software computer )i want search the text if it contain any word in that table .
View 2 Replies
Apr 19, 2010
Which technique is used in handling multilingual implementation? What is the best way to implement it?
View 3 Replies
Feb 27, 2011
In my new ASP.NET EF4 project, I find myself having to do a lot of maneuvering around null entities. For example, I may have a Project Entity with a related User Entity exposed through an Assignee property. Suppose I need to send an email to someone indicating who the Assignee is, I need to say:string x = "The Assignee is: " + TheProject.Assignee.Name;but I'll get an exception if there is no Assignee as the property is null (I want nulls by design) and I can't fetch the .Name property on that null.
View 4 Replies
Mar 5, 2010
how to display all the items in session in a repeater
View 1 Replies
Oct 31, 2010
I have a repeater with a label and textbox in the item template. How can I access the values from the label and the textbox after the user enters information into the textboxes.
View 2 Replies
May 3, 2010
I have an issue with update a gridview into a Repeater. So, my problem in the following:
- When I update an item (from other controls on this page) or create a new item - my gridview is not updated.
- But If I delete an item from the gridview - it deletes ok.
Why it's only updated when I delete an item? Btw, I tried to bind the repeater and the gridview myself but it didn't help.
View 3 Replies
Sep 4, 2010
I need to highlight active link in the menu. My menu is in the master page by the way. I'm looking for the best way to implement this?
View 3 Replies