Hi Almond,
We glad to inform you that your requirement [Entity Framework with MySQL Database] can be achieved using below steps.
[Add Entity Data Model]
1. In Models Add ADO.Net Entity Data Model
2. In the ADO.Net Entity Data Model Wizard add edmx file.
3. Select Generate from Database and click the New Connection.
4. Select MySQL Database and give the authorization information and select the database from MySQL.
For your convenience we have attached a sample. Could you please refer this sample and get back to us if you have any other queries.
Let us know if you have any other concerns.
Regards,
Satheeskumar S
Hi Almond,
Thanks for your interest in Syncfusion Products.
We have modified the sample as per your requirement to achieve “CRUD Operations with MySQL in Dialog Template Mode”. To achieve this we have changed the following things in the sample.
Please refer the below Steps to achieve Dialog Template Mode in JSON.
· Set the ActionMode to JSON.
· Set the Editing Properties.
· Set the EditMode to DialogTemplate.
· Call the Template file using DialogModeEditorTemplate.
Please refer the below code snippet for CRUD Operation.
[CSHTML]
//Enable the Dialog Editor Template
.Editing(edit =>
{
edit.EditMode(GridEditMode.DialogTemplate);
edit.DialogModeEditorTemplate("OrderEditorTemplate");
…
})
[Controller]
public ActionResult Index()
{
var data = new worldEntities1().cities.OrderBy(c => c.ID).ToList();
return View(data);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(PagingParams args)
{
IEnumerable data = new worldEntities1().cities.OrderBy(c => c.ID).ToList();
return data.GridJSONActions<city>();
}
For your convenience we have attached a sample. Could you please use this sample and get back to us if you have any other queries.
Let us know if you have any other concerns.
Regards,
Satheeskumar S
Hi Almond,
Thanks for your interest in Syncfusion Products.
If you want to perform validation in edmx file, this is not good for all cases because at the time of database modification, we need to update the edmx file. In that time the edmx file was refreshed. So the validation codes which are written inside the edmx file was cleared.
So we suggest you use MetadataType for validation. We have to refer the MetadataType to the class file (“city.cs”) which is placed inside the edmx file. Then we have to write the class file for validation (“CityMetaData.cs”). We have to refer few script files for validation.
Please refer the below code snippet.
[cshtml]
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript">
</script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
[city.cs]
[MetadataType(typeof(CityMetadata))] //CityMetadata is a class file for validation
public partial class city{
…..
}
[CityMetaData.cs]
public class CityMetaData
{
public int ID { get; set; }
[RegularExpression(@"[A-Za-z]*$", ErrorMessage = "Name must be string")]
[StringLength(15, ErrorMessage = "Name must be 15 characters.")]
public string Name { get; set; }
[RegularExpression(@"[A-Za-z]*$", ErrorMessage = "Country Code must be string")]
[StringLength(15, ErrorMessage = "Country Code must be 5 characters.")]
public string CountryCode { get; set; }
[RegularExpression(@"[A-Za-z]*$", ErrorMessage = "District must be string")]
[StringLength(15, ErrorMessage = "District must be 15 characters.")]
[Required]
public string District { get; set; }
public int Population { get; set; }
}
For your convenience we have attached a sample. Could you please refer this sample and get back to us if you have any queries.
Please Let us know if you have any other concerns.
Regards,
Satheeskumar S
Much thanks for the the immediate response.
I'll try and check the attached file and implement it based on my sample and will revert to you the results.
Thanks again :)
Hi Almond,
Sorry for the delay.
We glad to inform that we have
achieved your requirement("displaying validation error message next row of the
textbox"). We have added the Validation error message inside the new 'tr' to
achieve this. Please refer the below code
snippets.
[OrderEditorTemplate.cshtml]
@model
MySqlCRUD.Models.city
@Html.ValidationSummary(true)
<fieldset>
<b>Order Details</b>
<table
class="table-container">
<tr
style="height:20px;">
<td>
ID
</td>
<td>
@Html.TextBoxFor(model
=> model.ID)
</td>
</tr>
<tr
style="height:20px;padding-left:20px;">
<td></td>
<td
style="padding-right:20px;">
@Html.ValidationMessageFor(model =>
model.ID)
</td>
</tr>
-----------
-----------
</table>
</fieldset>
For
your convenience, we have modified the above given sample and the same can be
downloaded from the below link.
Sample: MySqlCRUD.zip
Please let us know if you have any other
concerns.
Regards,
Hariharan J.V.
Hi Almond,
Thanks for your patience.
We glad to inform that we have achieved your requirement ("displaying
validation error in tooltip"). We have modified the above given sample earlier
to achieve your requirement. We have added CSS file (“Validate.css”) and tooltip
image (“Validation.png”) to the content folder for displaying the validation message
in tooltip.
Please refer the below code snippets.
[Validate.css]
.field-validation-error{
background: transparent url("Content/Validation.png") no-repeat scroll;
margin-left: -33px;
margin-top: -20px;
padding: 20px 12px 22px 12px;
position: absolute;
width: 250px;
text-align: left;
vertical-align: middle;
color:Red;
}
[layout.shtml]
@(Html.Syncfusion().StyleManager().Combine(true).Minify(true)
.Register(component =>{
component.Add(ComponentType.Grid);
component.Add("~/Content/validate.css");
})
)
For your convenience we have attached the sample. Could you please use this sample and get back to us if you have any queries.
Sample- MySqlCRUD.zip
Please let us know if you have any other concerns.
Regards,
Satheeskumar S