 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 12th, 2006, 12:09 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes i am not sure what event to use. If the gridview has say 7 rows and the user clicks the checkbox on row 3 only row 3 in DB should be updated.
www.nursery-net.com
|
|

December 12th, 2006, 12:11 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If anyone has a working example of this i would be very greatful to see it working
www.nursery-net.com
|
|

December 12th, 2006, 12:13 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
ok.. then we have to start again.. let's try to build the logic of what you are trying to achieve...
do you really want a postback in every checkbox click???
what if the user have to check several rows?
HTH
Gonzalo
|
|

December 12th, 2006, 12:19 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
no, i suppose that would be bad practise. I just cant seem to get my head around this
www.nursery-net.com
|
|

December 12th, 2006, 12:21 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
ok.. so try the simple way...
put a button that commit the grid state (use the button click event) and loop the grid saving the checkbox state...
something similar to the code you have...
HTH
Gonzalo
|
|

December 12th, 2006, 12:24 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes i had considered using the button but decided against it has the button would only be used to update the checkbox state in DB
www.nursery-net.com
|
|

December 12th, 2006, 02:00 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
sorry i didn't understand you..
why not use the button???
HTH
Gonzalo
|
|

December 13th, 2006, 04:00 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to find the checked property, Actually I am adding a checkbox to the gridview and getting the same problem as shown above. I tried to set the checked property true, but could not find this property there. the gridview source code is here:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" Width="670px">
<Columns>
<asp:BoundField DataField="appno" HeaderText="Application Number" SortExpression="appno" />
<asp:BoundField DataField="Applicant" HeaderText="Applicant" SortExpression="Applicant" />
<asp:BoundField DataField="DateofApplication" HeaderText="Date of Application" SortExpression="DateofApplication" />
<asp:BoundField DataField="TitleofCase" HeaderText="Title of Case" SortExpression="TitleofCase" />
<asp:BoundField DataField="case_des" HeaderText="Case of Type" SortExpression="case_des" />
<asp:BoundField DataField="nature_des" HeaderText="Nature of Case" SortExpression="nature_des" />
<asp:CheckBoxField HeaderText="Submit?" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
I am not binding this checkbox to any datafield. I only want that if the user wishes to submit he should check the check box field or otherwise uncheck it. And when a button the form is clicked the status will be updated in the database.
|
|

December 13th, 2006, 05:07 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok, i cant use a button because the checkbox is there to send a value (1 or 0) back to DB. Then on another form the gridview row will be displayed if a the DB value is 1. I dont want the users to get confused by say checking 3 boxes then having to click a button, also what if they choose to uncheck a box and have to press the button again. Also the button click wont be redirected to any other page, so i would rather do it on checkbox click
www.nursery-net.com
|
|

December 13th, 2006, 05:29 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok, maybe i havent explained it properly..
Basically, i want a gridview with a templatefield (or checkboxfield) with a checkbox on it that when the user clicks the checkbox it sends a 1 or 0 value back to DB (1 for checked and 0 for unchecked)
www.nursery-net.com
|
|
 |