473,569 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit button function to update all GridView checkboxfields

How do I take my GridView and create a function that will update -all-
checkbox values for the submit button's OnClick event? I have posted both my
SQLDataSource and my GridView below:

<asp:SqlDataSou rce
ID="ds_dashboar d"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DashboardCon n %>"
SelectCommand=" Get_Customer_Da shboardGraphs"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" Update_Customer _DashboardGraph s"
UpdateCommandTy pe="StoredProce dure"

<UpdateParamete rs>
<asp:Paramete r Name="CustomerI D" Type="Int32" />
<asp:Paramete r Name="CurrentMo nthCollections"
Type="Int16" />
<asp:Paramete r Name="RevenueBy Month" Type="Int16" />
<asp:Paramete r Name="PDCsCCsMo nthly" Type="Int16" />
<asp:Paramete r Name="RevenueBy Client" Type="Int16" />

</UpdateParameter s>

</asp:SqlDataSour ce>

--------------------------------------------------------------------------------------

<table id="Table1" class="main_tab le" cellspacing="0" cellpadding="2"
border="1" runat="server">
<tr>
<td class="main_hea der">Filter Tool</td>
</tr>
<tr><td colspan="2"><br />For month: <asp:Label runat="server"
id="lblCurrentM onth" /><br /><br /></td></tr>
<tr><td>
<asp:GridView
ID="gv_dashboar d"
runat="server"
AutoGenerateCol umns="False"
AutoGenerateEdi tButton = "TRUE"
DataSourceID="d s_dashboard"
CellPadding="4"
ForeColor="#333 333"
ShowFooter="Tru e"
GridLines="None "
CssClass="Forma tFont">

<Columns>
<asp:TemplateFi eld HeaderText="Cus t #"
SortExpression= "CustomerID ">
<HeaderStyle HorizontalAlign ="Left"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" id="lblCustomer ID"
Text='<%# Bind("CustomerI D") %>' />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Cur rent Month Collections"
SortExpression= "Name">
<HeaderStyle HorizontalAlign ="Left"></HeaderStyle>
<ItemTemplate >
<asp:checkboxfi eld runat="server"
datafield="Curr entMonthCollect ions" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Month"
SortExpression= "Name">
<HeaderStyle HorizontalAlign ="Left"></HeaderStyle>
<ItemTemplate >
<asp:checkboxfi eld runat="server"
datafield="Reve nueByMonth" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="PDC s & CCS Monthly"
SortExpression= "Name">
<HeaderStyle HorizontalAlign ="Left"></HeaderStyle>
<ItemTemplate >
<asp:checkboxfi eld runat="server"
datafield="PMon thly" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Client"
SortExpression= "Name">
<HeaderStyle HorizontalAlign ="Left"></HeaderStyle>
<ItemTemplate >
<asp:checkboxfi eld runat="server"
datafield="Reve nueByClient" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
<EditRowStyle BackColor="#DDD DDD" />
<SelectedRowSty le BackColor="#DDD DDD" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />
</asp:GridView>
</td></tr>
<tr>
<td align="right">
<asp:Button CssClass="submi tbutton" Text="Update" ID="Button1"
OnClick="Update Fees" Runat="server" />
</td>
</tr>
</table>

--
dba123
Apr 24 '06 #1
2 6954
If I understand correctly you want to have the GridView to update
several rows in a single postback. The GridView control does not
support this functionality, it can only have one row in edit mode at a
time and send updates to the database for one row at a time only.
However, there are work arounds. To update several rows one alternative
is to iterate the GridView.Rows collection of the gridview, and issue
the necesarry Update statements to the database (you will probably need
to use FindControl method to find the controls and extract the values
within each row).

Apr 24 '06 #2
Thanks yes...I have used that to update textboxes before but not for
checkboxfield. How can I change my Function (that does what you say,
iterates through the rows) for a checkboxfield when a checkboxfield has no ID?

Here's the code I used to do just that but with a textbox...I need to know
how to change this to update all my checkboxes:

Public Sub UpdateCustomer_ DashboardGraphs (ByVal sender As Object, ByVal
e As System.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then
Dim intCustomerID As Integer = CType(gvr.FindC ontrol("lblCust omerID"),
Label).Text.Tri m()
Dim intCurrentMonth Collections As Integer =
CType(gvr.FindC ontrol("txtFeeG oalAZ"), TextBox).Text.T rim()
Dim intRevenueByMon th As Integer =
CType(gvr.FindC ontrol("txtFeeG oalIL"), TextBox).Text.T rim()
Dim intPDCsCCsMonth ly As Integer =
CType(gvr.FindC ontrol("txtFeeG oalIL"), TextBox).Text.T rim()
Dim intRevenueByCli ent As Integer =
CType(gvr.FindC ontrol("txtFeeG oalIL"), TextBox).Text.T rim()

ds_dashboard.Up dateParameters( "CustomerID").D efaultValue =
intCustomerID

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
intFeeGoalAZ
ds_dashboard.Up dateParameters( "RevenueByMonth ").DefaultV alue
= intFeeGoalIL
ds_dashboard.Up dateParameters( "PDCsCCsMonthly ").DefaultV alue
= intFeeGoalIL
ds_dashboard.Up dateParameters( "RevenueByClien t").DefaultValu e
= intFeeGoalIL
ds_dashboard.Up date()
End If
Next
End Sub

--
dba123
"Neutrino" wrote:
If I understand correctly you want to have the GridView to update
several rows in a single postback. The GridView control does not
support this functionality, it can only have one row in edit mode at a
time and send updates to the database for one row at a time only.
However, there are work arounds. To update several rows one alternative
is to iterate the GridView.Rows collection of the gridview, and issue
the necesarry Update statements to the database (you will probably need
to use FindControl method to find the controls and extract the values
within each row).

Apr 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
11269
by: Jimbo | last post by:
I am trying to right a script so that the "submit button" only appears when certain criteria has been met. I have tried putting it in an IF statement, without any luck. Maybe a function would allow me to do this? <input type="Submit" value="Update"> Any help would be greatly appreciated TIA
4
4283
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field that has been modified/clicked the form doesn't always submit. When it does work, a Stored procedure is passed form variables and updates to the db...
3
2593
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary in the bulleted list on top. I have 3 text boxes, and two RadioButtonList. and 3 buttons. One for Submit, Reset and Exit. If submit is pressed...
2
1890
by: Gayathri | last post by:
Please find the pasted html, <html> <script language="JavaScript" src="cal.js"></script><!-- Date only with year scrolling --> </head> <BODY onLoad="showDetails()"> <script language="javascript"> function validatePage(){
0
1738
by: mesut | last post by:
Hi there, I've a question. I would like to create a global update button to update all changed records gridview. e.g. A gridview contains 5 columns an 2 of the columns can be updated by the user. (other 3 are readonly) e.g. a column called Status is a dropdownlistbox the user can choose a status of the product and the other column called...
0
2797
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation. What happened is if I select cancel on my confirmation button, it executes the griedview postback which i assigned in my code behind. Please see my...
4
9773
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This sounds easy but the next requirement is that the GridView is editable. So I have included the SelectCommand and the UpdateCommand on the...
2
1443
by: mturner64 | last post by:
Good Day! I am fairly new to asp.net. I am using Microsoft VWD 2008 express edition. I have linked an Access 2007 database to my asp.net application using a gridview control. On the webpage are four text boxes allowing a user to input (first name, last name, donation amount and date). After the user inputs the values, I want them to click...
3
3405
by: mturner64 | last post by:
I am using Microsoft VWD 2008 express edition. I have linked an Access 2007 database to my asp.net application using a gridview control. On the webpage are four text boxes allowing a user to input (first name, last name, donation amount and date). After the user inputs the values, I want them to click the "Submit" button and have that...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.