Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

submit a formview without a button

Posted on 2011-10-15
7
Medium Priority
?
335 Views
Last Modified: 2012-05-12
Hi,

I want to be able to update the formview without having an asp:button, use the fact that the checkbox has been changed to trigger the update.  Any suggestions

Thanks, David
<asp:FormView ID="FormView7" runat="server" DataSourceID="SqlDataSource14" DataKeyNames="ConcernID" DefaultMode="Edit" >
                               <EditItemTemplate>
					<asp:CheckBox  AutoPostBack="true" ID="CheckBox1" runat="server" Checked='<%#Bind("ActualDateD1")%>'  >
                                   </asp:CheckBox>
                                   <asp:Button ID="Button3" runat="server" Text="Button"  CommandName="update"/>
                               </EditItemTemplate>
                               </asp:FormView>

Open in new window

0
Comment
Question by:djemanuel
  • 3
  • 2
  • 2
7 Comments
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 36974040
You can try with  inserting following code
<asp:FormView ........ OnItemInserting="editCheckBoxes".......... >

<InsertItemTemplate>
        <asp:CheckBox ID="CheckBox1" runat="server" Checked="true" /><br />
</InsertItemTemplate>
</asp:FormView>

Open in new window


Code Behind -

Protected void editCheckBoxes(object sender,  FormViewInsertEventArgs e)
{
        // Your Code... 
}

Open in new window


For more click below

https://forums.asp.net/t/1463375.aspx/1?CheckBox+in+FormView
0
 

Author Comment

by:djemanuel
ID: 36975763
Hi,  What is the code I need to use to submit the edit (not the insert)

Thanks, David
0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 36978127
Can you explain, what you really wanted to perform in your formview.
Means when you checked the checkbox what needs to be done ??
 
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:djemanuel
ID: 36978463
Hi,

Usually, in a formview, you need an asp:button with commandname="update" in order to save your changes to the database.    I want to get rid of this button and for the change to the database to be triggered by changing the value in the checkbox.

Thanks, David
0
 
LVL 28

Accepted Solution

by:
sybe earned 2000 total points
ID: 36978696
In simple HTML it would be

<input type="checkbox" onclick="this.form.submit();" />

That should not be difficult to do.
0
 

Author Comment

by:djemanuel
ID: 36978761
Hi

When I try that in the onclickchanged event I get the error.  

'this' is not a member of 'System.Web.UI.HtmlControls.HtmlForm'.

When I change it to "form.submit();", I get

 'submit' is not a member of 'System.Web.UI.HtmlControls.HtmlForm'.

I think we are getting close, thanks, David
0
 
LVL 28

Expert Comment

by:sybe
ID: 36978772
> 'this' is not a member of 'System.Web.UI.HtmlControls.HtmlForm'.

"this" is a client-side reference, it should not be used on the server ('System.Web.UI.HtmlControls.HtmlForm' is server-side stuff).

But maybe you should ignore my remark, as Asp.Net (or rather webforms) makes it quite complicated to do simple client-side stuff.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 1 hour left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question