I am currently building a CRUD operations on a entity called Payment.
When are click the pages, for instance, page 2, and try to delete the 9th item on page 2,
it will delete the 9th item on page 1 for me.
Here is my code:
protected void btnDelete_Click(object sender, CommandEventArgs e)
{
int paymentId = Convert.ToInt32(e.CommandArgument.ToString());
try
{
using (BillingApplicationDataContext dc = new BillingApplicationDataContext())
{
BLLPayment bllCorporation = new BLLPayment(dc);
bllCorporation.DeletePayment(paymentId);
}
Response.RedirectToRoute("ViewPaymentsRoute");
}
catch
{
Response.RedirectToRoute("ErrorPageRoute", new {
ErrorMsg = "Unable to delete Payment with Id " +
paymentId.ToString() + "." });
}
}
<asp:ListView ID="lstPayment" runat="server" OnPagePropertiesChanging="lstPayment_PagePropertiesChanging"
EnableViewState="false">
<LayoutTemplate>
<fieldset>
<legend>View Payments</legend>
<table cellpadding="0" cellspacing="0">
<tr>
<th>Id</th>
<th>Corporation</th>
<th>Service Contract</th>
<th>Payment Date</th>
<th>Payment Amount</th>
</tr>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</table>
</fieldset>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Id")%>' EnableViewState="false"/></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CorpName")%>' EnableViewState="false"/></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ServiceContractName")%>' EnableViewState="false"/></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PaymentDate")%>' EnableViewState="false" /></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Amount")%>' EnableViewState="false" /></td>
<td>
<%--<asp:Button runat="server" Text="Detail"
OnCommand="btnDetail_Click"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id")%>' EnableViewState="true"/>--%>
<asp:Button ID="btnDelete" Text="Delete" runat="server"
oncommand='btnDelete_Click' CommandArgument='<%# Eval("Id") %>'
OnClientClick="return ConfirmDelete();"/></td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="dataPager" runat="server" PagedControlID="lstPayment" EnableViewState="true">
<Fields>
<asp:NumericPagerField ButtonType="Link" />
</Fields>
</asp:DataPager>
<asp:Button runat="server"
ID="btnNew"
oncommand='btnNew_Click'
Text="New"/>
I think there may be something wrong with the page life cycle, but I do not know how to trace.
Why have you commented out
<asp:Button runat="server" Text="Detail"
OnCommand="btnDetail_Click"
**CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id")%>'** EnableViewState="true"/>
You are trying to retreive the paymentId but you are passing Id as the command argument. I think the line above is absolutely correct.
Related
I have a repeater that displays products, and the footer is input fields where you can choose a product from a db and add it to the repeater. The first field of the add line in the footer is a RadComboBox (with product names) and I want to update the other input fields with info from the db when SelectedIndexChanged for that combobox.
The problem is finding those other controls in my code-behind function.
protected void ProductSelected(Object source, EventArgs e)
{
RadComboBox temp = (RadComboBox)source;
Product p = session.Query<Product>()
.Where(x => x.Name == temp.SelectedItem.Text)
.FirstOrDefault();
var repParent = temp.Parent;
//var repParent = ((UpdatePanel)temp.NamingContainer.FindControl("UpdateHardwareLine")).ContentTemplateContainer;
((TextBox)repParent.FindControl("AddPartNumber")).Text = p.PartNumber;
((TextBox)repParent.FindControl("AddPartCost")).Text = p.Cost.ToString();
((TextBox)repParent.FindControl("AddUnitPrice")).Text = p.Price.ToString();
((TextBox)repParent.FindControl("AddQuantity")).Text = p.DefaultQuantity.ToString();
}
I've tried this 2 ways. At first I put the UpdatePanel in the footer of the repeater, and I changed repParent to the commented version. This produced some really weird results where it updated the input fields, but now they're above my entire repeater o_0?
Then I pulled the updatepanel out of the repeater, and it updates, but it refreshes the entire page. I would settle for just updating the footer, but it'd be neat to get those add/delete buttons working in the same update panel. How should I go about setting this up so it just refreshes for whats in this well?
as requested;
<asp:Repeater ID="repHW" runat="server" OnItemCommand="rep_ItemCommand">
<HeaderTemplate>
<table style="width:100%; padding-bottom:10px" id="HWtable">
<tr style="font-weight: bold"><td>Product</td><td>Part Number</td><td>Cost</td><td>Unit Price</td><td>Quantity</td><td>Price</td><td>Delete</td></tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<asp:HiddenField ID="Category" Value="Hardware" runat="server"/>
<td><asp:Label ID="Product" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Product.Name") %>' /></td> <!--TODO: make this clickable to edit -->
<td><asp:Label ID="PartNumber" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Product.PartNumber") %>' /></td>
<td><asp:Label ID="PartCost" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Product.Cost") %>' /></td>
<td><asp:Label ID="UnitPrice" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Product.Price") %>' /></td>
<td><asp:Label ID="Quantity" runat="server" Text='<%# Eval("Quantity") %>' /></td>
<td><asp:Label ID="Price" runat="server" Text='<%# Eval("Total") %>' /></td>
<td><asp:Button class="btn btn-danger" ID="DeleteHardware" runat="server" Text="Delete" CommandName="Delete" CommandArgument='<%# Container.ItemIndex %>'/></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<asp:UpdatePanel ID="UpdateHardwareLine" updatemode="Conditional" runat="server" ChildrenAsTriggers="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AddProduct" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:HiddenField ID="AddCategory" Value="Hardware" runat="server"/>
<td><telerik:RadComboBox runat="server" ID="AddProduct" ClientIDMode="static" Filter="Contains" EnableLoadOnDemand="true" AutoPostBack="true" OnSelectedIndexChanged="ProductSelected" OnDataBinding="LoadProductsByCategory"/></td>
<td><asp:TextBox runat="server" ID="AddPartNumber" ClientIDMode="static"/></td>
<td><asp:TextBox runat="server" ID="AddPartCost" ClientIDMode="static"/></td>
<td><asp:TextBox runat="server" ID="AddUnitPrice" ClientIDMode="static"/></td>
<td><asp:TextBox runat="server" ID="AddQuantity" ClientIDMode="static"/></td>
<td><asp:Button class="btn btn-success" ID="AddHardware" runat="server" Text="Add" CommandName="Add" CommandArgument='<%# DataBinder.Eval(Container, "ItemIndex") %>' onClientClick="return EmptyFieldCheck('Hardware');"/></td>
</ContentTemplate>
</asp:UpdatePanel>
</tr></table>
</FooterTemplate>
</asp:Repeater>
You could display the content of the footer in a separate table. Something like this:
<FooterTemplate>
<tr>
<td colspan="7">
<asp:UpdatePanel ID="UpdateHardwareLine" updatemode="Conditional" runat="server" ChildrenAsTriggers="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AddProduct" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<table style="width:100%;">
<tr>
<asp:HiddenField ID="AddCategory" Value="Hardware" runat="server"/>
<td><telerik:RadComboBox runat="server" ID="AddProduct" ClientIDMode="static" Filter="Contains" EnableLoadOnDemand="true" AutoPostBack="true" OnSelectedIndexChanged="ProductSelected" OnDataBinding="LoadProductsByCategory"/></td>
...
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</FooterTemplate>
The challenge would be to get that inner table aligned properly with the outer one. You would probably need to set CellPadding="0" and CellSpacing="0" for both tables as a first step.
I need some help about how to paging data from access data base.
I used asp:ListView and asp:DataPager like some example I found but the paging work with javascript and I want the paging will be friendly.
How I can put some of my code?
[edit]
this is the code:
<asp:ListView ID="tblProjects" runat="server" OnPagePropertiesChanging="tblProjects_PagePropertiesChanging">
<LayoutTemplate>
<ul class="ulProducts">
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<div class="divProduct">
<a rel='pics' href='GalleryEditor/pictures/<%# Eval("BigImageName") %>'>
<img src='GalleryEditor/pictures/<%# Eval("SmallImagesName") %>'
alt='<%# Eval("ImageDetail") %>' title='<%# Eval("ImageDetail") %>' />
</a>
</div>
</li>
</ItemTemplate>
<EmptyDataTemplate>
no data
</EmptyDataTemplate>
This the code behind:
protected void tblProjects_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
//set current page startindex, max rows and rebind to false
imagesPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
string page = Request.QueryString["p"];
if (!(FormValidator.IsNumber(page)))
page = "8800";
buildProducts(page);
}
void buildTitleAndDescription(string page)
{
// set page title
OleDbConnection conn0 = new OleDbConnection(#"Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath("GalleryEditor\\App_Data\\projects.mdb"));
OleDbCommand comm0 = new OleDbCommand("select ProjectName from Project where PlaceID=" + page, conn0);
OleDbDataReader reader0;
conn0.Open();
reader0 = comm0.ExecuteReader();
reader0.Read();
Page.Header.Title = reader0["ProjectName"].ToString();
reader0.Close();
conn0.Close();
//if (IsPostBack)
//{
// string Script = "<script type='text/javascript'>goToEnd();\n</script>";
// Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", Script);
//}
}
void buildProducts(string page)
{
// set page content
OleDbConnection conn = new OleDbConnection(#"Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath("GalleryEditor\\App_Data\\sb.mdb"));
OleDbCommand comm = new OleDbCommand("select SmallImagesName, BigImageName, ImageDetail from Images where PlaceID=" + page, conn);
conn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(comm);
da.Fill(ds);
tblProjects.DataSource = ds;
tblProjects.DataBind();
}
I do not mind change the code to better one and if I learn form it I will appreciate it.
All the example I found is for SQL and my data need to be on access.
Here is an example of asp listview you will have to define the querystring as follows.
<asp:ListView ID="ListView1" runat="server" DataKeyNames="bd_book_code"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Label ID="bd_book_codeLabel" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:Label ID="bd_isbnLabel" runat="server" Text='<%# Eval("bd_isbn") %>' />
</td>
<td>
<asp:Label ID="bd_titleLabel" runat="server" Text='<%# Eval("bd_title") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
</td>
<td>
<asp:Label ID="bd_book_codeLabel1" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:TextBox ID="bd_isbnTextBox" runat="server" Text='<%# Bind("bd_isbn") %>' />
</td>
<td>
<asp:TextBox ID="bd_titleTextBox" runat="server"
Text='<%# Bind("bd_title") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
<asp:TextBox ID="bd_book_codeTextBox" runat="server"
Text='<%# Bind("bd_book_code") %>' />
</td>
<td>
<asp:TextBox ID="bd_isbnTextBox" runat="server" Text='<%# Bind("bd_isbn") %>' />
</td>
<td>
<asp:TextBox ID="bd_titleTextBox" runat="server"
Text='<%# Bind("bd_title") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="bd_book_codeLabel" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:Label ID="bd_isbnLabel" runat="server" Text='<%# Eval("bd_isbn") %>' />
</td>
<td>
<asp:Label ID="bd_titleLabel" runat="server" Text='<%# Eval("bd_title") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
bd_book_code</th>
<th runat="server">
bd_isbn</th>
<th runat="server">
bd_title</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp:DataPager ID="DataPager1" runat="server" QueryStringField="pid">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="bd_book_codeLabel" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:Label ID="bd_isbnLabel" runat="server" Text='<%# Eval("bd_isbn") %>' />
</td>
<td>
<asp:Label ID="bd_titleLabel" runat="server" Text='<%# Eval("bd_title") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
QueryStringField="pid" will do the magic.
I'm an asp.net newbie. Basically, I have a DropDownList within and EditItemTemplate within a ListView. When a new item is selected in the drop down, the user would like to NOT have to click the LinkButton for update, but have the update happen automatically. I've experimented with the OnSelectedIndexChanged="ddlrank_itemChanged" using code behind, as well as OnChange="MyFoo()" in javascript, but the details of what to do are beyound me.
I hope I am including the code sample correctly. Any suggestions will be greatly appreciated. Thanks.
<asp:ListView ID="ListView1" runat="server" DataKeyNames="rankingID" DataSourceID="SqlDataSource1" OnItemUpdated="ListView1_Item_Updated">
<LayoutTemplate>
<table cellpadding="2" width="640px" border="1" runat="server" id="tblRankings">
<tr id="Tr1" runat="server">
<th id="Th1" runat="server">Action</th>
<th id="Th3" runat="server">Rank</th>
<th id="Th4" runat="server">Committee name</th>
<th id="Th5" runat="server">Committee type</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="RankingDataPager" PageSize="100">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate >
<tr id="Tr2" runat="server">
<td>
<asp:LinkButton ID="EditButton" runat="Server" Text="Edit" CommandName="Edit" />
</td>
<td valign="top">
<asp:Label ID="RankLabel" runat="Server" Text='<%#Eval("rank") %>' />
</td>
<td valign="top">
<asp:Label ID="CommitteeNameLabel" runat="Server" Text='<%#Eval("committeename") %>' />
</td>
<td valign="top">
<asp:Label ID="CommitteeTypeLabel" runat="Server" Text='<%#Eval("committeetype") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate >
<tr style="background-color: #ADD8E6">
<td>
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:LinkButton ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:DropDownList ID="ddlrank"
DataSourceID="sdsrank"
DataValueField="vchvalue"
DataTextField="vchvalue"
OnSelectedIndexChanged="ddlrank_itemChanged"
OnChange="MyFoo()"
SelectedValue='<%# Bind("rank") %>' runat="server" >
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="CommitteeNameTextBox" runat="server" Enabled="false" ReadOnly="true" Text='<%#Bind("committeename") %>'
MaxLength="200" /><br />
</td>
<td>
<asp:TextBox ID="CommitteeTypeTextBox" runat="server" Enabled="false" ReadOnly="true" Text='<%#Bind("committeetype") %>'
MaxLength="20" /><br />
</td>
</tr>
</EditItemTemplate>
</asp:ListView>
I think you are missing AutoPostBack="true" on your dropdownlist property. Hope it helps.
You're headed in the right direction. You can use "OnSelectedIndexChanged", or you can create a function in your codebehind page that handles the SelectedIndexChanged event. Either way, when the user makes a selection from the dropdown, you get a postback and that function is executed. In the function you can do whatever you want. In a case like this that might mean checking what the selected value is and setting other values on the screen based on the new selection. When the function exits, a new screen is sent to the user's browser with any updated data.
Thanks for the replies, they helped direct and refine my internet searching!
I finally found a simple solution.
It just requires two lines of code in the OnSelectedIndexChanged code-behind function defined on the dropdownlist:
protected void ddlrank_itemChanged(object sender, EventArgs e)
{
ListViewDataItem item = (ListViewDataItem)((DropDownList)sender).Parent;
ListView1.UpdateItem(item.DisplayIndex, false);
}
In Nridubai website,i am using listview EditTemplate for editing purpose. In my EditTemplate, there are controls like..
<asp:TextBox ID="txtEditEventName" runat="server"
Text='<%# Bind("event_name") %>' />
And a few more controls like dropdownlist, calender controls. Now I want to validate using javascript on these controls, but its not working.
Eg.
var eventStatus=document.getElementById("<%=txtEditEventName.ClientID%>").value;
I am not using validation controls. Please help me how to use javascript for validation on EditTemplate Controls? My EditTemplate structure is like the following:
<EditItemTemplate>
<td class="command"><asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
<asp:LinkButton ID="LinkButton2" runat="server" Text="Update" CommandName="Update" />
</td>
<div class="header">View Details for '<%# Eval("event_name")%>'</div>
<tr>
<td class="edit" colspan="6" >
<div class="details">
<table class="detailview" cellpadding="0" cellspacing="0">
<tr>
<td>Event Name:</td>
<td>
<asp:TextBox ID="txtEditEventName" runat="server"
Text='<%# Bind("event_name") %>' />
</td>
<td>VenueAddress :</td>
<td>
<asp:TextBox ID="txtEditVenue" runat="server" Text='<%# Bind("venue") %>' />
</td>
</tr>
<tr>
<td>Country :</td>
<td>
<asp:DropDownList ID="lstEditCountry" runat="server"
Width="174" />
</td>
<td>Event Status:</td>
<td>
<asp:DropDownList ID="lstEditStatus" runat="server" Width="175px" >
<asp:ListItem value='0' Selected="True">-Select-</asp:ListItem>
<asp:ListItem >In-Progress</asp:ListItem>
<asp:ListItem >Completed</asp:ListItem>
<asp:ListItem >Aborted</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Category :</td>
<td>
<asp:DropDownList ID="lstEditCategory" runat="server"
Width="174" />
</td>
</tr>
<tr>
<td>Start Date:</td>
<td>
<asp:TextBox ID="txtEditStartDate" runat="server"
Text='<%# Bind("start_date", "{0:dd/MM/yyyy}") %>' />
</td>
<td>End Date:</td>
<td>
<asp:TextBox ID="txtEditEndDate" runat="server"
Text='<%# Bind("end_date","{0:dd/MM/yyyy}") %>' />
</td>
</tr>
</table>
<div class="footer command">
<asp:LinkButton ID="LinkButton1" runat="server" Text="Close" CommandName="Cancel" />
</div>
</div>
</td>
</tr>
</EditItemTemplate>
You can access the elements on ItemDataBound and emit their ClientIDs for your JavaScript to use:
ItemDataBound:
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
StringBuilder vars= new StringBuilder();
if (ListView1.EditItem != null)
{
TextBox txtEditStartDate = ListView1.EditItem.FindControl("txtEditStartDate") as TextBox;
TextBox txtEditEndDate = ListView1.EditItem.FindControl("txtEditEndDate") as TextBox;
//example js, however I recommend passing the ClientIDs to functions
vars.Append(String.Format("var txtEditStartDate='{0}';" txtEditStartDate.ClientID);
vars.Append(String.Format("var txtEditStartDate='{0}';", txtEditEndDate.ClientID );
ClientScriptManager.RegisterStartUpScript(this.GetType(), "validationVars", vars.ToString(), true);
}
}
***Old Answer, the .NET way************
EditTemplate:
<asp:TextBox ID="txtEditEventName" runat="server"
Text='<%# Bind("event_name") %>' />
<asp:RequiredFieldValidator
id="rfvEditEventName"
ClientValidationFunction="txtEditEventNameClientValidate"
ControlToValidate="txtTitle"
runat="server"
Display="dynamic">*
</asp:RequiredFieldValidator>
JS:
function txtEditEventNameClientValidate(sender, args) {
if (args.Value == '') {
args.IsValid = false; // field is empty
//so something
}
else {
//do something
}
}
Put the validation javascript in the EditTemplate itself. This way, when it switches to edit-mode, the control will be in the context.
I have two datalists. One works like a menu where you click on a link to fill the othe datalist.
I also have added a next and previous linkbutton to move between the different "pages" so that you do not have to change using the menu datalist.
Now in code behind depending on which values I get from the database I add a RegularExpressionValidator.
This works great until I want to use the next button (or previous for that matter). Even if all the controls that are checked are valid when compared with the RegularExpressionValidator I never get to load the new values.
The next and previous buttons fires the datalist selected index change event and then I check if it is the previous or next button that was clicked.
But the previous and next buttons are numb. They don't even fire the event.
It is like clicking on the background. Nothing happens.
I have chcked the PageIs.Valid and it is true.
Does anyone have a clue what it could be that is causing this behavior?
Thanks in advance!
Some of the texts down there is in Swedish but it shouldn't matter for the code.
rev_checkfieldvalue.ControlToValidate = "tb_detailValue";
switch (iDataTypeId)
{
case 2:
rev_checkfieldvalue.ValidationExpression = #"^\d*[0-9 ]+$";
rev_checkfieldvalue.Text = "Fältet får endast innehålla siffror och mellanslag.";
break;
case 3:
break;
case 4:
break;
case 5:
rev_checkfieldvalue.ValidationExpression = #"\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*";
rev_checkfieldvalue.Text = "Fältet får endast innehålla en e-postadress.";
break;
}
e.Item.Controls.AddAt(32, rev_checkfieldvalue);
<asp:DataList ID="dl_componentInfo" DataKeyField="ComponentId" runat="server" OnItemDataBound="dl_componentInfo_OnItemDataBound" OnItemCommand="dl_componentInfo_OnItemCommand">
<ItemTemplate>
<table>
<tr>
<td colspan="2"><asp:Label ID="lb_componentName" SkinID="lblHeader" runat="server" Text='<%# Eval("ComponentName") %>' /></td>
</tr>
<tr>
<td colspan="2">Fält markerade med * är obligatoriska</td>
</tr>
<tr>
<td> </td>
<td>
<asp:DataList ID="dl_details" OnItemDataBound="dl_details_OnItemDataBound" runat="server">
<ItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label ID="lbl_detailName" Text='<%# Eval("DetailName") %>' runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_custDetName" runat="server" />
</td>
<td align="left">
<%--Always hidden values--%>
<asp:Label ID="lbl_detailTypeId" Visible="false" Text='<%# Eval("DetailTypeId") %>' runat="server" />
<asp:Label ID="lbl_detailId" Visible="false" Text='<%# Eval("DetailId") %>' runat="server" />
<asp:Label ID="lbl_dataTypeId" Visible="false" Text='<%# Eval("DataTypeId") %>' runat="server" />
<asp:Label ID="lbl_customerEventValueId" Visible="false" Text='<%# Eval("CustomerEventValueId") %>' runat="server" />
<asp:Label ID="lbl_reqFld" Visible="false" Text='<%# Eval("ReqFld") %>' runat="server" />
<%--Sometimes visible values--%>
<asp:Label ID="lbt_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
<asp:Label ID="lbtb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
<asp:Label ID="lbth_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
<asp:Label ID="lbc_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
<asp:DropDownList ID="dd_detailValue" Visible="false" runat="server"></asp:DropDownList>
<%--Om det ska gå att markera/avmarkera alla så använd AJAX--%>
<asp:CheckBoxList ID="cbl_detailValue" RepeatDirection="Horizontal" RepeatLayout="flow" Visible="false" runat="server" />
<asp:CheckBox ID="cb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
<asp:TextBox ID="tb_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server" />
<asp:TextBox ID="ta_detailValue" Visible="false" Text='<%# Eval("PresetDetailValue") %>' runat="server"></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
<table width="600">
<tr>
<td>
<asp:LinkButton id="lb_previous" Text="Föregående" CommandName="Previous" runat="server"/>
</td>
<td>
<asp:LinkButton id="lb_next" Text="Nästa" CommandName="Next" runat="server"/>
</td>
</tr>
</table>
</FooterTemplate>
</asp:DataList>
I thought I solved the issue but it just stopped checking.
So for case two you accept any non-empty string of digits and spaces.
Is that your intent?