|
I have a modal popup form and i want to insert/delete into a database and show/remove in a data table. Does anyone know how to do this. Here is the code for the modal:
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!--
<div class="modal-content">
<div class="modal-header">
Point of Contact
</div>
<div class="modal-body">
<div class="name-text-container">
<span id="fname-text">First Name:</span>
<span id="mname-text">MI:</span>
<span id="lname-text">Last name*:</span><br>
</div>
<div class="name-input-container">
<form>
<input id="fname-input" type="text" name="fname" size="15">
<input id="mname-input" type="text" name="mname" maxlength="1" size="1">
<input id="lname-input" type="text" name="lname" size="16"><br>
</form>
</div>
<div class="email-text-container">
<span id="email-text">Email*:</span><br>
</div>
<div class="email-input-container">
<form>
<input id="email-input" type="text" name="email" size="47"><br>
</form>
</div>
<div class="contact-text-container">
<span id="telephone-text">Telephone:</span>
<span id="fax-text">Fax:</span><br>
</div>
<div class="contact-input-container">
<form>
<input id="telephone-input" type="text" name="telephone" size="20">
<input id="fax-input" type="text" name="fax" size="19"><br>
</form>
</div>
</div>
<!--
<div class="modal-footer">
<button type="button" data-dismiss="modal">Cancel</button>
<button type="button" data-dismiss="modal">Save</button>
</div>
|
|
|
|
|
1. Create a jquery function on click event of the on save button.
2. Remove the data-dismiss attribute from the save button.
3. Start writing function in javascript =>
function Save()
{
var Employee = {
fname: $("#fname").val(),
mname: $("#mname").val(),
lname: $("#lname").val()
};
$.ajax({
type:"post",
url:"write url of server method here",
data:JSON.stringify(Employee),
dataType:"json",
success:function(data){
alert("Data saved successfully !");
}
});
}
4. Create server method for save with class as parameter.public string Save(Employee emp).
5. Return the result from that method as string.
6. Get all records on pageload function, your grid will be updated.
7. Similarly for delete create a function and call on the click event of delete button.
|
|
|
|
|
SqlConnection con;
con = new SqlConnection(@"Data Source=SEPEHR;Integrated Security=True;server=(local);Database=TestDatabaseByYall");
con.Open();
SqlCommand cmd;
cmd = new SqlCommand("INSERT INTO tbl_CustInfo (codemeli,mydate,name,idnasb,iddevice,email,mobile,tel,adress)" + "VALUES (@codemeli,@mydate,@name,@idnasb,@iddevice,@email,@mobile,@tel,@adress)", con);
cmd.Parameters.AddWithValue("@codemeli", txtcodemeli.Text.Trim().ToString());
cmd.Parameters.AddWithValue("@mydate", mydat);
statuse = false;
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@idnasb", dridnasb.SelectedItem.Value);
cmd.Parameters.AddWithValue("@iddevice", drdevice.SelectedItem.Value);
cmd.Parameters.AddWithValue("@email", txtemail.Text.Trim());
cmd.Parameters.AddWithValue("@mobile", txtmobile.Text.Trim().ToString());
cmd.Parameters.AddWithValue("@tel", txttel.Text.Trim().ToString());
cmd.Parameters.AddWithValue("@adress", txtAdress.Text.Trim());
cmd.ExecuteNonQuery();
lblresult.Text = "Successful!";
SqlCommand cmd2;
string vart="1";
string varf="0";
cmd2 = new SqlCommand("INSERT INTO tbl_Customer_Statuse (idcustomer,level1,level2,level3,level4,Complate)" + "VALUES (@codemeli,@level1,@level2,@level3,@level14,@Complate)", con);
cmd2.Parameters.AddWithValue("@codemeli",txtcodemeli.Text.Trim());
cmd2.Parameters.AddWithValue("@level1",vart);
cmd2.Parameters.AddWithValue("@level2",varf);
cmd2.Parameters.AddWithValue("@level3",varf);
cmd2.Parameters.AddWithValue("@level4",varf);
cmd2.Parameters.AddWithValue("@Complate",varf);
cmd2.ExecuteNonQuery();
con.Close();
|
|
|
|
|
Huh?
Well, good luck with that!
|
|
|
|
|
but in second table did not fill
|
|
|
|
|
Have you tried debugging your code? Have you checked the values being passed to your query? Are you getting errors?
As a side note, please make it a habit to use the using statement when dealing with objects that eat resources such as SqlConnection and SqlCommand to ensure that the object will be properly closed and disposed after you use them.
Finally, place your connectionString within your config file so you can easily switch and modify the settings when needed without compiling your code.
modified 17-Oct-16 18:21pm.
|
|
|
|
|
|
At least one visible problem seems to be that you have mispelled the @level4 parameter. In the insert statement you have @level14 but in the parameters you have @level4 (without 1). That should cause an exception in your code.
In overall you seem to be missing few elemental parts
- You don't have any error handling
- you don't dispose objects etc.
I suggest going through Properly executing database operations[^]
modified 17-Oct-16 15:35pm.
|
|
|
|
|
thank you 
|
|
|
|
|
You're welcome
|
|
|
|
|
Probably just poor planning on my part, but I thought I could get away with it.
I have a model that populates a page with items in a store. On get it grabs from the database and populates the view.
Now I have a filter bar wrapped in form tags. In the filter bar is 2 textboxes to filter by price, which works in postback. The next is a ul of li's for checkboxes that returns null.
I thought all input elements would postback fine. The textboxes do.
This is my view
using (Html.BeginForm())
{
<ul id="selectBrand" class="dropdown-menu selectBrand-menu" role="menu">
@foreach (model_storeBrowse_Brands_Filters bfilter in Model.Brand_Filters)
{
<li role="presentation">
@Html.CheckBox(bfilter.Name, bfilter.Checked, new { @class = "dropdown-menu-control", onchange = "this.form.submit();" })
@Html.Label(bfilter.Name)
</li>
}<br />
</ul>
}
|
|
|
|
|
Well the idea was good but the design was bad. Guess somebody else had the same problem and created
@Html.CheckboxListFor which was difficult to implement because I had to change my model and CSS.
But it works now, so those are many querystrings less that I have to deal with.
I didn't want to get caught up in a querystring for every filter chosen to narrow results.
CBL(F)[^]
<div id="selectBrand" class="dropdown-menu selectBrand-menu" role="menu">
<div class="filter-bar-checkboxes">
@Html.CheckBoxListFor(x => x.Brands_Posted.BrandIDs, x => x.Brands_Available, x => x.ID, x => x.Name, x => x.Brands_Selected)
</div>
<div class="filter-bar-applyfilters">
<button id="js_filterBrand" type="submit" class="btn btn-primary">Apply Filter</button>
</div>
</div>
|
|
|
|
|
I want to track the Cut,Copy and Paste Action in c#
|
|
|
|
|
Access to the local clipboard is limited for security reasons.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
sarwajeet singh wrote: I want to track the Cut,Copy and Paste Action in c# What do you mean?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I want to create a toggle switch where the user has the choice of Purchase or Delivery. I've seen the Yes/No and True/False type of toggle switches but has anyone seen or have a way of creating a toggle switch with a that many letters.
|
|
|
|
|
Something like this[^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In a web form 2010 application, I am creating letters that need to be sent to various customers that are generated in html and are sent to 2 or 3 customers at the at different addresses. However each letter needs to be the same. The only difference is the mailing address. Thus I need each letter to be generated on separate pages. Thus I would like to know what html command can be used to made certain each letter is printed on separate pages. Thus can you tell me what the command would be?
|
|
|
|
|
You can use CSS Page-break-after Property[^]. However, I would recommend using a pdf writer or pdf sdk like iTextSharp instead. You'll have more control.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
PS. I also upvoted this since I noticed 2 people downvoted it. Not sure why they would do that.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
A hub with a link. Alternatively, if you really want to know then try using Google - that's why it was created.
|
|
|
|
|
i need to send the confirmation message to patient like ur appointement is fixed with some doctor...
how to write a code in c#..please help me
|
|
|
|
|
It seem like you've not even googled the slightest info available to you but this should help.
If your web app is reatricted to your country then search for an sms campany that offers this service at a cheap and steady rate, they will provide an api to allow you work with your app platform, java, asp.net, perl etc as the case may be.
Follow the provided samples and integrate with your app.
If its an international target then look for a company that can serve you well with speed and server uptime.
|
|
|
|
|
How To Download BioPlugIn ActxControls
|
|
|
|
|