i cannot find my hiddenfield2 in the back end code . So how can i get the value of this hiddenfiled using asp.net(vb)
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="list_election">
<form>
<asp:DropDownList ID = "ddlElectionCategorie" runat="server" AutoPostBack="true">
</asp:DropDownList>
</form>
</div>
<div class="row">
<asp:Repeater ID="rpVoteList" runat="server" >
<ItemTemplate>
<div class="col-md-4 ">
<div class="voter">
<h4><%# Eval("List_Nom")%></h4>
<asp:HiddenField ID="hfListId" runat="server" Value='<%# Eval("Id")%>' />
<form>
'this is a nested radiobutton list in a repeater
<asp:HiddenField ID="HiddenField2" runat="server" Value='<%# Eval("Id")%>' />
<asp:RadioButtonList ID="RbCandidat" runat="server"></asp:RadioButtonList>
</form>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Content>
C#:
foreach (RepeaterItem item in rpVoteList.Items)
{
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
var hf= (HiddenField)item.FindControl("HiddenField2")
}
}
Or
protected void rpVoteList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
var value = (HiddenField) e.Item.FindControl("HiddenField2")).Value;
}
Related
I have multiple tabs on my page and currently I am binding all dropdownlists on every tab at page load.
I want to bind the dropdownlists only when the tab is selected. I also want to clear the gridviews when the tab is changed.
This is my HTML code
<li>
<input type="radio" id="tab1d" name="tabs1" runat="server"/>
<label for="tab1d">Search</label>
<div id="tab-content1d" class="tab-content animated fadeIn" style="background-color:white; padding:10px; ">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label4" runat="server" Text="Select Platform"></asp:Label>
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" CssClass="inputs" Width="150px"></asp:DropDownList>
<asp:Label ID="Label10" runat="server" Text="Select Family Name"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" CssClass="inputs" Width="150px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList>
<asp:Label ID="Label11" runat="server" Text="Select price Level"></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" CssClass="inputs" Width="150px" ></asp:DropDownList>
<asp:Button ID="Button7" runat="server" Text="Search" CssClass="buttons" OnClick="Button7_Click"/><br /><br />
<div id="gdvLeft">
<asp:GridView ID="gdvFamilyname" runat="server" EnableViewState="True" class="grid" RowStyle-CssClass="rows"></asp:GridView>
</div>
<div id="gdvRight">
<asp:GridView ID="gdvQuantity" runat="server" EnableViewState="True" class="grid" RowStyle-CssClass="rows"></asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</li>
Hi Himani, Try like this -
<input type="radio" value="Click Me" onclick="rdioClick();" />
In Javascript -
function rdioClick() {
var GridView1 = document.getElementById('GridView1');
GridView1.innerHTML = "";
}
Thanks :)
issue.aspx
<div id="model_input_stock" runat="server" class="form-group well">Dynamically need to insert new textbox and lable with in new div</div>
Issue.aspx.cs
protected void Button_Grid_DT_Assign_Click(object sender, EventArgs e)
{
//use assigned in selecting issued quantity view
foreach(var item in StockCode_List)
{
model_input_stock.InnerHtml.???
}
}
Is their any best alternative way, i'm new in ASP.NET??
You can add an ASP.net panel inside of your div for first and then inside of your foreach loop initialize a new textbox and add it to your panel:
Textbox txt = new Textbox();
txt.id = "txt1";
Txt.Text = "My Text";
Panel.Controls.Add(txt);
Use the following code to do so:
Default.aspx:
<div>
<asp:TextBox ID="txtRows" runat="server"></asp:TextBox>
<asp:Button SkinID="b" ID="btnAddRow" runat="server" Text="Click To Proceed" OnClick="btnAddRow_Click" Width="220px" />
<asp:GridView SkinID="grv" ID="GridViewProducts" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="SL No.">
<ItemTemplate>
<%#Container.DataItemIndex + 1%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category">
<ItemTemplate>
<asp:DropDownList ID="ddlCategoryID" runat="server" AutoPostBack="True">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Name">
<ItemTemplate>
<asp:DropDownList ID="ddlItemID" runat="server" AutoPostBack="True">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unit Type">
<ItemTemplate>
<asp:DropDownList ID="ddlUnitTypeID" runat="server" AutoPostBack="True">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:TextBox ID="txtDes" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div style="padding: 10px 0px;">
<asp:Panel ID="Panel1" runat="server" Visible="false">
<asp:Button ID="btnSave" runat="server" Text="Submit" OnClick="btnSave_Click" />
<asp:Label ID="lblMsg" runat="server"></asp:Label>
</asp:Panel>
</div>
In the code-behind, Default.aspx.cs:
private void AddRowsToGrid()
{
List<int> noofRows = new List<int>();
int noOfInputs = Convert.ToInt32(txtRows.Text);
for (int i = 0; i < noOfInputs; i++)
{
noofRows.Add(i);
}
GridViewProducts.DataSource = noofRows;
GridViewProducts.DataBind();
if (GridViewProducts.Rows.Count > 0)
{
Panel1.Visible = true;
}
else
{
Panel1.Visible = false;
}
}
protected void btnAddRow_Click(object sender, EventArgs e)
{
AddRowsToGrid();
}
Finally you'll have the following output giving input 10:
i have a 1) Text filed
2) Drop down list
3)List Box
Im write code for Drop down list selected value add the the list box and text filed , i can remove the list box value but cant remove the text filed value, please how to write code remove the same adding value for text filed and list box
<div class="col-sm-3">
<asp:TextBox ID="txtQlt" runat="server" CssClass="form-control" Width="348px" OnTextChanged="txtQlt_TextChanged" ReadOnly="true"></asp:TextBox>
</div><div class="col-md-1" style="margin-left:115px;">
<asp:Label ID="Label4" runat="server" ForeColor="Red" Text="*" ></asp:Label>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-2">
<asp:Label ID="Label6" runat="server" Text="Quality reference" Font-Bold="True" Font-Names="arial, helvetica, sans-serif" Font-Size="13px"></asp:Label>
</div>
<div class="col-sm-3">
<asp:DropDownList ID ="cmbQualityRef" runat ="server" CssClass="form-control" Width="250px" >
</asp:DropDownList>
<asp:ListBox ID="lstValue" runat="server" CssClass="content" Rows="5" ValidationGroup="save"
Width="250" ></asp:ListBox>
</div>
<asp:ImageButton ID="btnAdd" runat="server" CssClass="button" Text="Add" ValidationGroup="add"
OnClick="btnAdd_Click" ImageUrl="~/img/Add.png"/>
<asp:ImageButton ID="btnImageRemove" runat="server" OnClick="btnImageRemove_Click"
ImageUrl="~/img/Remove.png" />
<div class="col-md-1" style="margin-left:16px;">
<asp:Label ID="Label7" runat="server" ForeColor="Red" Text="*" ></asp:Label>
</div>
</div>
Code Behind
protected void btnImageRemove_Click(object sender, ImageClickEventArgs e)
{
try
{
if (lstValue.SelectedItem != null)
{
lstValue.Items.Remove(lstValue.SelectedItem);
}
//lstValue.Items.Remove(lstValue.SelectedItem.Text);
}
catch (Exception)
{
}
}
private void AddToList()
{
if (lstValue.Items.Count > 0)
{
txtQlt.Text = txtQlt.Text + "," + cmbQualityRef.SelectedItem.ToString();
}
else
{
txtQlt.Text = cmbQualityRef.SelectedItem.ToString();
}
ListItem itm = new ListItem();
itm.Value = cmbQualityRef.SelectedValue;
itm.Text = cmbQualityRef.SelectedItem.ToString();
lstValue.Items.Add(itm);
lstValue.Items.Remove("");
}
protected void btnAdd_Click(object sender, EventArgs e)
{
AddToList();
lstValue.Items.Remove("");
}
Based on your question as I understand it, when you are removing the selected item, also set the textbox to empty.
if (lstValue.SelectedItem != null)
{
lstValue.Items.Remove(lstValue.SelectedItem);
txtQlt.Text = txtQlt.Text.Replace(lstValue.SelectedItem.ToString(), "");
}
Finally its working
if (lstValue.SelectedItem != null)
{
txtQlt.Text = txtQlt.Text.Replace(lstValue.SelectedItem.ToString(), "").Trim();
lstValue.Items.Remove(lstValue.SelectedItem);
}
its my code i want to hide div which have id selnumber (when i select form 60/61 and show a text message "It is form 60/61" at the place of div) but when select pan then show the div.
<div id="selpan">
<asp:DropDownList ID="ddlpan" runat="server">
<asp:ListItem>---Select---</asp:ListItem>
<asp:ListItem>PAN</asp:ListItem>
<asp:ListItem>FORM 60/61</asp:ListItem>
</asp:DropDownList> </div>
</td><div id="selnumber">
<td colspan="3">
<asp:Label ID="add_no" runat="server" Font-Bold="True" Font-Names="Verdana"
Font-Size="10pt" Font-Strikeout="False" Text="File Number"></asp:Label>
</td><td>
<asp:TextBox ID="tbnumber" runat="server" ontextchanged="tbnumber_TextChanged"></asp:TextBox>
</td>
</div>
you can add onchange event on dropdownlist and though javascript you can check if selected item in the list in form 60/61 then hide the div else show the div.
<div id="selpan">
<asp:DropDownList AutoPostBack="true" ID="ddlpan" runat="server" onselectedindexchanged="ddlpan_SelectedIndexChanged">
<asp:ListItem>---Select---</asp:ListItem>
<asp:ListItem>PAN</asp:ListItem>
<asp:ListItem>FORM 60/61</asp:ListItem>
</asp:DropDownList> </div>
<asp:Label Visible="false" ID="lblMessage" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt" Font-Strikeout="False" Text="File Number"></asp:Label>
<div id="selnumber" Visible="false" runat="server">
<asp:Label ID="add_no" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt" Font-Strikeout="False" Text="File Number"></asp:Label>
<asp:TextBox ID="tbnumber" runat="server" ontextchanged="tbnumber_TextChanged"></asp:TextBox>
</div>
.....
protected void ddlpan_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlpan.SelectedIndex == 1)
{
selnumber.Visible = true;
lblMessage.Visible = false;
}
else if (ddlpan.SelectedIndex == 2)
{
selnumber.Visible = false;
lblMessage.Visible = true;
lblMessage.Text = "It is form 60/61";
}
}
Two ways you can do this.
You can either use onSelectedIndexChanged() event like #Sruthi already said but that will include an unnecessary call to server and take time.
Second and better way to do this is to use javascript onchange() event and save both time and resources.
Javascript code.
<script type="text/javascript">
function change() {
var DropdownList = document.getElementById('<%=ddlpan.ClientID %>');
var SelectedIndex = DropdownList.selectedIndex;
var message = document.getElementById('message');
var selnumber = document.getElementById('selnumber');
if (SelectedIndex == 2) {
selnumber.style.display = "none";
message.style.display = "block";
}
else {
selnumber.style.display = "block";
message.style.display = "none";
}
}
</script>
ASP.NET code..
<div id="selpan">
<asp:DropDownList ID="ddlpan" runat="server" onchange="change()">
<asp:ListItem>---Select---</asp:ListItem>
<asp:ListItem>PAN</asp:ListItem>
<asp:ListItem>FORM 60/61</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="label" runat="server"></asp:Label></div>
</td><div id="selnumber" style="">
<td colspan="3">
<asp:Label ID="add_no" runat="server" Font-Bold="True" Font-Names="Verdana"
Font-Size="10pt" Font-Strikeout="False" Text="File Number"></asp:Label>
</td><td>
<asp:TextBox ID="tbnumber" runat="server" ></asp:TextBox>
</td>
</div>
<div id="message" style="display:none">
<label>This is form 60/61</label>
</div>
Using RegisterClientScriptBlock I have no problem whith displaying the warning alert but after I close the pop up the binding becomes a real mess. The weird thing is that when I try to debug it and go with F10 the binding is ok.
This this a code behind method:
protected void lvContratFonds_OnItemDeleting(object source, ListViewDeleteEventArgs e)
{
try
{
ListView lv = (ListView)source;
int contratId = int.Parse(((HiddenField)lv.Parent.FindControl("hdnContratId")).Value);
int anneeFiscaleId = int.Parse(((HiddenField)lv.Items[e.ItemIndex].FindControl("hdnAnneeFiscaleId")).Value);
int contratFondId = int.Parse(((HiddenField)lv.Items[e.ItemIndex].FindControl("hdnContratFondId")).Value);
ImageButton lnkSupprimerContratFonds = (ImageButton)lv.Items[e.ItemIndex].FindControl("lnkSupprimerContratFonds");
string errMsg = String.Empty;
errMsg = ContratFondBLL.DeleteSingleContratFond(contratFondId, ((PageProjet)Page).ProjetId);
if (errMsg.Length == 0)
{
ContratsFondsTransBLL.DeleteAllContratFondTransByContratId(contratFondId, ((PageProjet)Page).ProjetId);
}
else
{
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "ClientScript", "alert('" + Resources.GPWebResource.errContratFondDelete.ToString() + "')", true);
}
bindContrats();
}
catch(Exception ex)
{
throw (ex);
}
}
<LayoutTemplate>
<div class="wideContainer">
<asp:Literal ID="ltlOrphanWarning" runat="server" Text="OrphanWarning"></asp:Literal>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
<div class="contentDiv">
<asp:LinkButton CssClass="showbtn" ID="btnAjoutContrat" runat="server" Text="AjouterContratAddContract" OnClick="btnAjouterContrat_Click" Visible="false" />
</div>
</div>
</LayoutTemplate>
<ItemTemplate>
<div class="wideContainer">
<div class="contentDiv">
<asp:HiddenField ID="hdnContratId" runat="server" Value='("ContratId") ' />
<div class="titleCellContrats smallCell"><asp:literal ID="ltlContratNum" runat="server" Text="ContratNum"/></div>
<div class="titleCellContrats largeCell"><asp:literal ID="ltlType" runat="server" Text="Type"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlDateDND8" runat="server" Text="DateDND8"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlDtOctroi" runat="server" Text="ApprovalDateOctroi"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlFundsTot" runat="server" Text="ValContratTotal"/></div>
<div class="modCellTitle"> </div>
</div>
<div class="contentDiv">
<div class="contentCellContrats smallCell"><asp:Literal ID="numeroContrat" runat="server"/></div>
<div class="contentCellContrats largeCell boldText"><asp:Literal ID="typeContrat" runat="server" /></div>
<div class="contentCellContrats mediumCell"><asp:Literal ID="dateDND8" runat="server" /></div>
<div class="contentCellContrats mediumCell">
<asp:Literal ID="dateOctroi" runat="server"/>
<asp:CheckBox ID="chkbxOctroi" runat="server" AutoPostBack="false" Enabled="false" />
</div>
<div class="contentCellContrats mediumCell"><asp:Literal ID="ltlTotal" runat="server"/></div>
<div class="modCellContrats">
<asp:ImageButton ID="btnModifierContrat" runat="server" Tooltip="ModifierModify" ImageUrl="~/WebUI/images/icones/edit_16x16.gif" CommandName="Edit" Visible="false" />
<asp:ImageButton ID="btnDeleteContrat" runat="server" Tooltip="Supprimer" ImageUrl="~/WebUI/images/icones/delete_16x16.gif" CommandName="Delete" OnClientClick="SuppContratDeleteContract" Visible="false"/>
</div>
</div>
<div class="contentDiv">
<asp:Literal ID="ltlCommentaires" runat="server"/>
</div>
<div class="contentDiv">
<div class="titleCellContrats Fonds">
<div class="alLeft"><asp:literal ID="ltlfunds" runat="server" Text="ValContrat"/></div>
<div class="alRight smText"><asp:LinkButton ID="lnkAjouterContratFond" runat="server" Text="AjoutEF" OnClick="lnkAjouterContratFond_Click" Visible="false"/></div>
</div>
<asp:ListView
ID="lvContratFonds" runat="server"
InsertItemPosition="None"
OnItemDataBound="lvContratFonds_OnItemDataBound"
ItemPlaceholderID="afficherFonds"
OnItemEditing="lvContratFonds_OnItemEditing"
OnItemUpdating="lvContratFonds_OnItemUpdating"
OnItemCanceling="lvContratFonds_OnItemCanceling"
OnItemDeleting="lvContratFonds_OnItemDeleting"
OnItemInserting="lvContratFonds_OnItemInserting"
OnItemCreated="lvContratFonds_OnItemCreated" >
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="afficherFonds" />
</LayoutTemplate>
<ItemTemplate>
<div class="contentDiv">
<div class="contFondsRows">
<div class="contentCellContrats ContFonds"><asp:Literal ID="lblAnneeFiscaleEF" runat="server" /></div>
<div class="contentCellContrats ContFonds"><asp:Literal ID="lblFondsContrat" runat="server" /></div>
<div class="contentCellContrats ContFonds">
<strong><asp:Literal ID="ltlDeltaTitle" runat="server" Text="Delta" />:</strong>
<asp:Literal ID="ltlContratFondDelta" runat="server" />
</div>
<div class="modCellCntrFonds">
<asp:ImageButton class="smText" ID="btnModifierContratFonds" runat="server" Tooltip="ModifierModify" ImageUrl="~/WebUI/images/icones/edit_16x16.gif" Height="10" Width="10" CommandName="Edit" Visible="false" />
<asp:ImageButton
class="smText"
ID="lnkSupprimerContratFonds"
runat="server"
Tooltip="Supprimer"
ImageUrl="~/WebUI/images/icones/delete_16x16.gif"
Height="10"
Width="10"
CommandName="Delete"
OnClientClick="SuppFondsDeleteFunds"
Visible="false"/>
<asp:HiddenField ID="hdnContratFondId" runat="server" Value='("ContratFondId") ' />
<asp:HiddenField ID="hdnContratId" runat="server" Value='("ContratId") ' />
<asp:HiddenField ID="hdnAnneeFiscaleId" runat="server" Value='("AnneeFiscaleId") ' />
<asp:HiddenField ID="hdnEF" runat="server" Value='("efID") ' />
</div>
</div>
</div>
</ItemTemplate>
<EditItemTemplate>
<div class="contentDiv">
<asp:HiddenField ID="hdnEditTemplate" runat="server" Value='True' />
<div class="contFondsRows">
<div class="contentCellContrats ContFonds"><asp:DropDownList ID="ddlEF_AF_Prog" runat="server" DataTextField="DisplayField" DataValueField="EF_ID" OnSelectedIndexChanged="ddlEF_Changed" AutoPostBack="true" AppendDataBoundItems="false"></asp:DropDownList></div>
<div class="contentCellContrats ContFonds"><asp:TextBox ID="txtFondsContrat" runat="server"></asp:TextBox> $</div>
<div class="contentCellContrats ContFonds">
<strong><asp:Literal ID="ltlDeltaTitle" runat="server" Text="Delta" />:</strong>
<asp:Literal ID="ltlContratFondDelta" runat="server" />
</div>
<div class="modCellCntrFonds">
<asp:ImageButton
class="smText"
ID="btnEnregistrerContratFonds"
runat="server"
Tooltip="EnregistrerRegister"
ImageUrl="~/WebUI/images/icones/save_16x16.gif"
Height="12"
Width="12"
CommandName="Update" />
<asp:ImageButton class="smText" ID="btnAnnulerContratFonds" runat="server" Tooltip="Cancel" ImageUrl="~/WebUI/images/icones/undo1_16x16.gif" Height="12" Width="12" CommandName="Cancel" CausesValidation="false"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="FondMontantObligAmntReqd" Display="Dynamic" ControlToValidate="txtFondsContrat" />
<asp:CompareValidator id="CheckFormat1" runat="server" ControlToValidate="txtFondsContrat" Operator="DataTypeCheck" Type="Currency" Display="Dynamic" ErrorMessage="InvalidCurrency" />
<asp:HiddenField ID="hdnContratFondId" runat="server" Value='("ContratFondId") ' />
<asp:HiddenField ID="hdnContratId" runat="server" Value='("ContratId") ' />
<asp:HiddenField ID="hdnAnneeFiscaleId" runat="server" Value='("AnneeFiscaleId") ' />
<asp:HiddenField ID="hdnEF" runat="server" Value='("efID") ' />
</div>
</div>
</div>
<div id="transPanel" class="contentDiv" runat="server">
<asp:UpdatePanel ID="updPnlTransactions" runat="server">
<ContentTemplate>
<uc2:FMASTransControl ID="uc2FMASTransControl" runat="server" ContratMode="true" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</EditItemTemplate>
<InsertItemTemplate>
<div class="contentDiv">
<div class="contFondsRows">
<div class="contentCellContrats ContFonds"><asp:DropDownList ID="ddlEF_AF_Prog" runat="server" DataTextField="DisplayField" DataValueField="EF_ID" AutoPostBack="true" AppendDataBoundItems="false"></asp:DropDownList></div>
<div class="contentCellContrats ContFonds"><asp:TextBox ID="txtFondsContrat" runat="server"></asp:TextBox> $</div>
<div class="contentCellContrats ContFonds">
<strong><asp:Literal ID="ltlDeltaTitle" runat="server" Text="Delta" />:</strong>
<asp:Literal ID="ltlContratFondDelta" runat="server" Text="AD_InfoNA" />
</div>
<div class="modCellCntrFonds">
<asp:ImageButton ID="btnAjouterCF" runat="server" ClientIDMode="Static" Tooltip="EnregistrerRegister" ImageUrl="~/WebUI/images/icones/save_16x16.gif" Height="12" Width="12" CommandName="Insert" ValidationGroup="insertFondGroup"/>
<asp:ImageButton ID="btnAnnulerCF" runat="server" Tooltip="Cancel" ImageUrl="~/WebUI/images/icones/undo1_16x16.gif" Height="12" Width="12" OnClick="btnAnnulerCF_Click" CausesValidation="false" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="FondMontantObligAmntReqd" Display="Dynamic" ControlToValidate="txtFondsContrat" ValidationGroup="insertFondGroup" />
<asp:CompareValidator id="CheckFormat1" runat="server" ControlToValidate="txtFondsContrat" Operator="DataTypeCheck" Type="Currency" Display="Dynamic" ErrorMessage="InvalidCurrency" />
<asp:HiddenField ID="hdnContratId" runat="server" Value='("ContratId") ' />
</div>
</div>
</div>
</InsertItemTemplate>
</asp:ListView>
</div>
<div class="contentDiv"> </div>
</div>
</ItemTemplate>
<EditItemTemplate>
<div class="wideContainer">
<asp:HiddenField ID="hdnContratId" runat="server" Value='("ContratId") ' />
<asp:HiddenField ID="hdnEditTemplate" runat="server" Value='True' />
<div class="contentDiv">
<div class="titleCellContrats smallCell"><asp:literal ID="ltlContratNum" runat="server" Text="ContratNum"/></div>
<div class="titleCellContrats largeCell"><asp:literal ID="ltlType" runat="server" Text="Type"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlDateDND8" runat="server" Text="DateDND8"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlDtOctroi" runat="server" Text="ApprovalDateOctroi"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlFundsTot" runat="server" Text="Delta"/></div>
<div class="modCellTitle"> </div>
</div>
<div class="contentDiv">
<div class="contentCellContrats smallCell"><asp:TextBox ID="txtContrat" runat="server" MaxLength="8"></asp:TextBox></div>
<div class="contentCellContrats largeCell">
<asp:DropDownList ID="ddlTypeContrat" runat="server" DataTextField="NomChampFieldNm" DataValueField="TypeContratId"></asp:DropDownList>
</div>
<div class="contentCellContrats mediumCell"><uc1:DateControl ID="dateDND8" runat="server" /></div>
<div class="contentCellContrats mediumCell">
<uc1:DateControl ID="dateOctroi" runat="server"/>
<asp:CompareValidator ID="cmpOctroiAfterDND8" runat="server" ControlToCompare="dateDND8$txtDate" ControlToValidate="dateOctroi$txtDate"
ErrorMessage="ErrDateOctroi " Type="Date" Operator="GreaterThanEqual" ToolTip="ErrEndDate ">*</asp:CompareValidator>
<asp:CheckBox ID="chkbxOctroi" runat="server" AutoPostBack="false" onclick="GetTodayDateForOctroi();" />
</div>
<div class="contentCellContrats mediumCell"><asp:Literal ID="ltlTotal" runat="server" Text="" /></div>
<div class="modCellContrats">
<asp:ImageButton ID="btnEnregistrerContrat" runat="server" Tooltip="EnregistrerRegister" ImageUrl="~/WebUI/images/icones/save_16x16.gif" CommandArgument='("ContratId") ' CommandName="Update" />
<asp:ImageButton ID="btnAnnulerContrat" runat="server" Tooltip="Cancel" ImageUrl="~/WebUI/images/icones/undo1_16x16.gif" CommandArgument='("ContratId") ' CommandName="Cancel" />
</div>
</div>
<div class="contentDiv paleBackground <%# Container.DisplayIndex % 2 == 0 ? "" : "altRow" bordered">
<asp:TextBox ID="txtCommentairesContrats" runat="server" Width="100%" MaxLength="250"></asp:TextBox>
<ajx:TextBoxWatermarkExtender ID="tbweCommentairesContrats" runat="server" TargetControlID="txtCommentairesContrats" WatermarkText=" tbweCommentContats" WatermarkCssClass="watermarked" />
</div>
<div class="contentDiv">
<div class="titleCellContrats Fonds">
<div class="alLeft"><asp:literal ID="ltlfunds" runat="server" Text="ValContrat"/></div>
<div class="alRight"><asp:LinkButton class="smText" ID="lnkAjouterContratFond" runat="server" Text="<%$Resources:GPWebResource,AjoutEF" OnClick="lnkAjouterContratFond_Click" Visible="false"/></div>
</div>
<asp:ListView
ID="lvContratFonds"
runat="server"
InsertItemPosition="None"
OnItemDataBound="lvContratFonds_OnItemDataBound"
ItemPlaceholderID="afficherFonds2"
OnItemEditing="lvContratFonds_OnItemEditing"
OnItemUpdating="lvContratFonds_OnItemUpdating"
OnItemCanceling="lvContratFonds_OnItemCanceling"
OnItemDeleting="lvContratFonds_OnItemDeleting"
OnItemInserting="lvContratFonds_OnItemInserting"
OnItemCreated="lvContratFonds_OnItemCreated" >
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="afficherFonds2" />
</LayoutTemplate>
<ItemTemplate>
<div class="contentDiv">
<div class="contFondsRows">
<div class="contentCellContrats ContFonds"><asp:Literal ID="lblAnneeFiscaleEF" runat="server" /></div>
<div class="contentCellContrats ContFonds"><asp:Literal ID="lblFondsContrat" runat="server" /></div>
<div class="contentCellContrats ContFonds">
<strong><asp:Literal ID="ltlDeltaTitle" runat="server" Text="Delta" />:</strong>
<asp:Literal ID="ltlContratFondDelta" runat="server" />
</div>
<div class="modCellCntrFonds">
<asp:ImageButton class="smText" ID="btnModifierContratFonds" runat="server" Tooltip="ModifierModify" ImageUrl="~/WebUI/images/icones/edit_16x16.gif" Height="10" Width="10" CommandName="Edit" Visible="false" />
<asp:ImageButton class="smText" ID="lnkSupprimerContratFonds" runat="server" Tooltip="Supprimer"
ImageUrl="~/WebUI/images/icones/delete_16x16.gif" Height="10" Width="10" CommandName="Delete"
OnClientClick="SuppFondsDeleteFunds" Visible="false"/>
<asp:HiddenField ID="hdnContratFondId" runat="server" Value='("ContratFondId") ' />
<asp:HiddenField ID="hdnContratId" runat="server" Value='("ContratId") ' />
<asp:HiddenField ID="hdnAnneeFiscaleId" runat="server" Value='("AnneeFiscaleId") ' />
<asp:HiddenField ID="hdnEF" runat="server" Value='("efID") ' />
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
</div>
<div class="contentDiv"> </div>
</div>
</EditItemTemplate>
<InsertItemTemplate>
<div class="wideContainer">
<asp:HiddenField ID="hdnContratId" runat="server" Value='("ContratId") ' />
<asp:HiddenField ID="hdnEditTemplate" runat="server" Value='True' />
<div class="contentDiv">
<div class="titleCellContrats smallCell"><asp:literal ID="ltlContratNum" runat="server" Text="ContratNum"/></div>
<div class="titleCellContrats largeCell"><asp:literal ID="ltlType" runat="server" Text="Type"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlDateDND8" runat="server" Text="DateDND8"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlDtOctroi" runat="server" Text="ApprovalDateOctroi"/></div>
<div class="titleCellContrats mediumCell"><asp:literal ID="ltlFundsTot" runat="server" Text="Delta"/></div>
<div class="modCellTitle"> </div>
</div>
<div class="contentDiv <%# Container.DisplayIndex % 2 == 0 ? "" : "altRow" ">
<div class="contentCellContrats smallCell"><asp:TextBox ID="txtContrat" runat="server" MaxLength="8"></asp:TextBox></div>
<div class="contentCellContrats largeCell">
<asp:DropDownList ID="ddlTypeContrat" runat="server" DataTextField="NomChampFieldNm" DataValueField="TypeContratId"></asp:DropDownList>
</div>
<div class="contentCellContrats mediumCell"><uc1:DateControl ID="dateDND8" runat="server" /></div>
<div class="contentCellContrats mediumCell">
<uc1:DateControl ID="dateOctroi" runat="server" />
<asp:CompareValidator ID="cmpOctroiAfterDND8" runat="server" ControlToCompare="dateDND8$txtDate" ControlToValidate="dateOctroi$txtDate"
ErrorMessage="ErrDateOctroi " Type="Date" Operator="GreaterThanEqual" ToolTip="ErrEndDate ">*</asp:CompareValidator>
</div>
<div class="contentCellContrats mediumCell"><asp:Literal ID="ltlTotal" runat="server" Text="" /></div>
<div class="modCellContrats">
<asp:ImageButton ID="btnAjouterContrat" runat="server" Tooltip="Add " ImageUrl="~/WebUI/images/icones/add_16x16.gif" CommandName="Insert" />
<asp:ImageButton ID="btnAnnulerContrat" runat="server" Tooltip="Cancel" ImageUrl="~/WebUI/images/icones/undo1_16x16.gif" CausesValidation="false" OnClick="btnAnnulerAjouterContrat_Click"/>
</div>
</div>
<div class="contentDiv bordered">
<asp:TextBox ID="txtCommentairesContrats" runat="server" Width="100%" MaxLength="250"></asp:TextBox>
<ajx:TextBoxWatermarkExtender ID="tbweCommentairesContrats" runat="server" TargetControlID="txtCommentairesContrats" WatermarkText="tbweCommentContats" WatermarkCssClass="watermarked" />
</div>
</div>
</InsertItemTemplate>
can you please explain what you mean by "the binding becomes a real mess"? Do you get duplicates?
Also, are you able to post the code for your bindContrats() method?
Edit 1:
ScriptManager.RegisterClientScriptBlock(lvContratFonds, typeof(ListView), "ClientScript", "alert('" + Resources.GPWebResource.errContratFondDelete.ToString() + "')", true);
Edit 2:
if (errMsg.Length == 0)
{
ContratsFondsTransBLL.DeleteAllContratFondTransByContratId(contratFondId, ((PageProjet)Page).ProjetId);
bindContrats(); // re-bind data
}
else
{
e.Cancel = true;
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "ClientScript", "alert('" + Resources.GPWebResource.errContratFondDelete.ToString() + "')", true);
/* don't re-bind! */
}