In my code I have two Gridview. One is for adding Education Details and other for adding Experience details.
<asp:GridView runat="server" ID="gvDetails" CssClass="mydatagrid" HeaderStyle-CssClass="Grdheader" ShowFooter="true" AllowPaging="true" PageSize="10" AutoGenerateColumns="false" ShowHeaderWhenEmpty="true" OnRowDeleting="gvDetails_RowDeleting" OnSelectedIndexChanged="gvDetails_SelectedIndexChanged">
<HeaderStyle CssClass="headerstyle" />
<Columns>
<asp:BoundField DataField="rowid" HeaderText="No" ReadOnly="true" />
<asp:TemplateField HeaderText="Qualification">
<ItemTemplate>
<asp:TextBox ID="txtqualification" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvQualification" ControlToValidate="txtqualification" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Specialization">
<ItemTemplate>
<asp:TextBox ID="txtspecialization" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvSpec" ControlToValidate="txtspecialization" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_" ></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Board/University">
<ItemTemplate>
<asp:TextBox id="txtboard" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvBoard" ControlToValidate="txtboard" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Year">
<ItemTemplate>
<asp:TextBox id="txtyear" runat="server" onkeypress="CheckNumeric(event);" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvYear" ControlToValidate="txtyear" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Percentage">
<ItemTemplate>
<asp:TextBox id="txtpercentage" runat="server" onkeypress="CheckNumeric(event);" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvPerc" ControlToValidate="txtpercentage" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group_"></asp:RequiredFieldValidator>
</ItemTemplate>
<FooterTemplate >
<asp:Button ID="Button1" runat="server" Text="Add" ValidationGroup ="Group_" OnClick="gvDetails_SelectedIndexChanged" CssClass="grdadd"/>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="true" DeleteText="X" ControlStyle-CssClass="grdDelete"/>
</Columns>
<footerstyle CssClass="footerGrd"/>
</asp:GridView>
Above Grid for adding Education details.
<asp:GridView runat="server" ID="gvExperience" CssClass="mydatagrid" HeaderStyle-CssClass="Grdheader" ShowFooter="true" AllowPaging="true" PageSize="10" AutoGenerateColumns="false" ShowHeaderWhenEmpty="true" OnRowDeleting="gvExperience_RowDeleting" OnSelectedIndexChanged="gvExperience_SelectedIndexChanged">
<HeaderStyle CssClass="headerstyle" />
<Columns>
<asp:BoundField DataField="rowidE" HeaderText="No" ReadOnly="true" />
<asp:TemplateField HeaderText="Name of Organisation">
<ItemTemplate>
<asp:TextBox ID="txtOrganisation" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvorg" ControlToValidate="txtOrganisation" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Position held">
<ItemTemplate>
<asp:TextBox ID="txtposition" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvpos" ControlToValidate="txtposition" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Nature of duty">
<ItemTemplate>
<asp:TextBox ID="txtNature" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfvnature" ControlToValidate="txtNature" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Duration From">
<ItemTemplate>
<asp:TextBox id="txtDuration" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfduratin" ControlToValidate="txtDuration" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Duration
To">
<ItemTemplate>
<asp:TextBox id="txtTo" runat="server" Height="60px" Width="100%" BorderStyle="None" />
<asp:RequiredFieldValidator ID="rfTo" ControlToValidate="txtTo" runat="server"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup ="Group1_"></asp:RequiredFieldValidator>
</ItemTemplate>
<FooterTemplate >
<asp:Button ID="Button2" runat="server" ValidationGroup ="Group1_" Text="Add" OnClick="Button2_Click" CssClass="grdadd"/>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="true" DeleteText="X" ControlStyle-CssClass="grdDelete"/>
</Columns>
<footerstyle CssClass="footerGrd"/>
</asp:GridView>
I want validation to both grid. I used the required field for all the textbox in the grid but it validate the below grid also. In button click add i want to add a javascript for the validation
Related
I have a popup in asp.net using JavaScript that I need to display variables from text boxes on the web page. The variables are coming back blank so I believe I am missing something. I think I'm missing something in the document.getElementById either I should be using something different of I'm using it incorrectly
This is my JavaScript
<!DOCTYPE html>
<title></title>
<script type = "text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
var ppn = document.getElementById("<%= pifPassportNbr %>")
var pid = document.getElementById("<%= pifIssueDate.Text %>")
var pil = document.getElementById("<%= pifIssueLoc.Text %>")
var ped = document.getElementById("<%= pifExpirationDate.Text %>")
if (ppn == null || pid == null || pil == null || ped == null) {
if (confirm(ppn + " " + pid + " " + pil + " " + ped)) {
confirm_value.value = "Yes";
}
else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
}
</script>
This is my asp.net code
<tr>
<td style="padding-top: 5px;">
<asp:UpdatePanel ID="updPassport" runat="server" UpdateMode="Conditional" Visible="false" >
<ContentTemplate>
<asp:Table runat="server" ID="tblPassport" GridLines="Both" CellSpacing="0" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1.5px" Font-Size="9pt">
<asp:TableHeaderRow VerticalAlign="Bottom" Height="20px">
<asp:TableHeaderCell ColumnSpan="2" CssClass="lblValueBlackFont" HorizontalAlign="Left" BackColor="#B0CCFF" >
 <asp:Label ID="lblPassportTbl_Title" Text="Passport Information" runat="server" />
</asp:TableHeaderCell>
<asp:TableHeaderCell ID="thcPassport_Sync" runat="server" ColumnSpan="2" CssClass="lblValueBlackFont" HorizontalAlign="Right" BackColor="#B0CCFF" >
<asp:Label ID="lblPassportSyncDate_Title" runat="server" Text="GIF Info Sync'd with TS: " Font-Size="8pt" Visible="False" />
<asp:Label ID="lblPassportSyncDate" runat="server" Font-Size="8pt" Visible="False" />
 <asp:Label ID="lblPassportSyncBy_Title" runat="server" Text="By: " Font-Size="8pt" Visible="False" />
<asp:Label ID="lblPassportSyncBy" runat="server" Font-Size="8pt" Visible="False" />
 
</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:TableHeaderRow VerticalAlign="Bottom" HorizontalAlign="Center" CssClass="gv_Header" Font-Size="9pt">
<asp:TableHeaderCell runat="server" ID="thcPassport_Fields" Text=" Fields" />
<asp:TableHeaderCell runat="server" ID="thcPassport_TS" Text="Existing Data in Travel Studio" Width="350"/>
<asp:TableHeaderCell runat="server" ID="thcPassport_PIF" Text="Data Submitted on GIF" Width="420" />
<asp:TableHeaderCell runat="server" ID="thcPassport_Update" Text="Accept New Value" Width="75px" Font-Size="8pt"
ToolTip="When checked, TS data for the field will be updated with the data in the GIF column" />
</asp:TableHeaderRow>
<asp:TableRow VerticalAlign="Top" Font-Size="9pt" >
<asp:TableCell>
 
<asp:TextBox ID="rhNationality" runat="server" ReadOnly="True" Text="Nationality:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsNationality" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="75%" />
<asp:TextBox ID="tsNationalityID" runat="server" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Visible="false" />
<asp:TextBox ID="tsPassportCountryID" runat="server" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Visible="false"/>
<asp:TextBox ID="tsPassportID" runat="server" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Visible="false" />
</asp:TableCell>
<asp:TableCell VerticalAlign="Middle">
<asp:TextBox ID="pifNationality" runat="server" Text="Nationality" BorderStyle="Solid" BorderColor="White" ToolTip="Value entered is not in available list. Please choose a correct value from the dropdown." ForeColor="Red" />
<asp:DropDownList ID="ddlNationality" runat="server" AutoPostBack="True" Width="75%" />
<asp:TextBox ID="pifNationalityID" runat="server" Text="ID" BorderStyle="Solid" BorderColor="White" Visible="false" />
<asp:TextBox ID="pifNationalityCountryID" runat="server" Text="ID" BorderStyle="Solid" BorderColor="White" Visible="false" />
</asp:TableCell><asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbNationality" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
 
<asp:TextBox ID="rhPassportNbr" runat="server" ReadOnly="True" Text="Passport Number:" BorderStyle="Solid"
BorderColor="White" Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsPassportNbr" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifPassportNbr" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbPassportNbr" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
 
<asp:TextBox ID="rhPassportName" runat="server" ReadOnly="True" Text="Passport Name:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsPassportName" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifPassportName" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" MaxLength="60" Width="100%" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbPassportName" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
 
<asp:TextBox ID="rhIssueLoc" runat="server" ReadOnly="True" Text="Place of Issue:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsIssueLoc" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifIssueLoc" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" MaxLength="50" Width="100%" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbIssueLoc" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
 
<asp:TextBox ID="rhIssueDate" runat="server" ReadOnly="True" Text="Issue Date:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsIssueDate" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" Width="95%" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifIssueDate" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" Width="95%" />
  <asp:Label ID="pifIssueDate_Err" runat="server" Text="The value entered is not a date. Please use mm/dd/yyyy format." Font-Size="7pt" CssClass="lblValueRed" Visible="False" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbIssueDate" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow VerticalAlign="Top">
<asp:TableCell>
 
<asp:TextBox ID="rhExpirationDate" runat="server" ReadOnly="True" Text="Expiration Date:" BorderStyle="Solid" BorderColor="White"
Font-Bold="True" Font-Size="8pt" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="tsExpirationDate" runat="server" Text="No Existing Value" ReadOnly="True" BorderStyle="Solid" BorderColor="White" />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="pifExpirationDate" runat="server" Text="No Data Entered" BorderStyle="Solid" BorderColor="White" />
  
<asp:Label ID="pifExpDate_Err" runat="server" Text="The value entered is not a date. Please use mm/dd/yyyy format." Font-Size="7pt" CssClass="lblValueRed" Visible="False" />
</asp:TableCell>
<asp:TableCell HorizontalAlign="Center">
<asp:CheckBox ID="ckbExpirationDate" runat="server" Checked="false" />
</asp:TableCell>
</asp:TableRow></asp:Table><table width="98%" cellpadding="20px" style="margin-top: 5px;margin-bottom: 3px" >
<tr valign="middle">
<td>
<asp:Label runat="server" ID="lblPassportUpdateMsg" Text="Unable to create or update this passenger's passport data."
CssClass="ErrorMessageRed" Width="100%" />
<asp:Label ID="lblNationality" runat="server" Text=" *Invalid Nationality " Font-Size="8pt" Visible="False" Font-Bold="True" ForeColor="Red" />
</td>
<td align="right">
<asp:Button ID="btnPassportUpdate" visible = "true" text="Update" CssClass="btnUpdate" runat="server" OnClientClick="Confirm()"/>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
In your javascript, it looks like you are selecting the document id based of the text box value (textbox_id.Text)? Try selecting the client id property of the text box, then select the javascript text value. Something like this:
var ppn = document.getElementById("<%= pifPassportNbr.ClientID %>").value;
var pid = document.getElementById("<%= pifIssueDate.ClientID %>").value;
var pil = document.getElementById("<%= pifIssueLoc.ClientID %>").value;
var ped = document.getElementById("<%= pifExpirationDate.ClientID %>").value;
I am trying to use a repeater and use ajax instead of the "EnableEventValidation='true'" but I get the error below on page unload. When I click on the button in the repeater the repeater1_ItemCommand does not get referenced
Error:
System.Collections.ListDictionaryInternal System.ArgumentException:
Invalid postback or callback argument. Event validation is enabled
using in configuration or <%#
Page EnableEventValidation="true" %> in a page
Code:
<asp:ToolkitScriptManager ID="MainSM" EnablePageMethods="true" runat="server" ScriptMode="Release" LoadScriptsBeforeUI="true">
</asp:ToolkitScriptManager>
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<table id="myTable" width="700" border="1" class = "mMMGrid" frame="box">
<th align=left>Page Image</th><th align=left>Page #</th><th align=left >Page Sequnce</th><tbody>
<tr>
<td width="15%">
<div id = "dPage" runat="server" >
<asp:ImageButton ID="imbtnCourseLink" runat="server" ImageUrl='<%#imPath(DataBinder.Eval(Container, "DataItem.ChunkFilePath"))%>' OnClick="imlink2" Width="75px" Height="75px" />
</div>
</td>
<td width="15%">
<strong>Pages</strong> : <asp:label ID="lblPage" Text='<%# Eval("Page")%>' runat="server"></asp:label> <br/>
</td>
<td width="65%">
<asp:ImageButton ID="imbtUp" runat="server" ImageUrl="~/SiteImages/go-up.png" Width="40" height="40" CommandName="UP" CommandArgument='<%# Eval("Page")%>'/>
<asp:ImageButton ID="imbtDown" runat="server" ImageUrl="~/SiteImages/go-down.png" Width="40" Height="40" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<triggers>
<asp:asyncpostbacktrigger controlid="imbtUp" eventname="Click" />
<asp:asyncpostbacktrigger controlid="Repeater1" eventname="ItemCommand" />
</triggers>
</asp:UpdatePanel>
<br />
</td>
</tr>
</tbody>
</table>
</ItemTemplate>
</asp:Repeater>
I need to identify a control that I have in the EmptyDataTemplate of a GridView within a jquery function call.
In the code-behind, you can do this to get all of the controls:
Control tFooterControls = grid.Controls[0].Controls[0];
then a FindControl("") to get a specific control.
Is there an equivalent in jquery?
I can't use the ID because I use the same ID for the Gridview control as the EmptyDataTemplate to make the code-behind simpler.
This is my GridView markup:
<div id="DelegateGridWrapper">
<asp:GridView ID="DelegateInfoGridView" runat="server"
AutoGenerateColumns="false" Caption="Delegate Information"
CaptionAlign="Top" CssClass="grid" RowStyle-Wrap="true"
HorizontalAlign="Left" ShowFooter="true"
AllowPaging="true" PageSize="5" ShowHeaderWhenEmpty="false" onrowediting="DelegateInfoGridView_RowEditing"
onrowcancelingedit="DelegateInfoGridView_RowCancelingEdit" onrowdeleting="DelegateInfoGridView_RowDeleting"
onrowupdating="DelegateInfoGridView_RowUpdating"
ondatabound="DelegateInfoGridView_DataBound"
onrowcommand="DelegateInfoGridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Recipient ID">
<ItemTemplate>
<asp:Label ID="deligvLblRecipientID" runat="server" Text='<%# Bind("RecipientID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delegate" ItemStyle-Wrap="false">
<ItemTemplate>
<asp:Label ID="deligvLblRecipientName" runat="server" Text='<%# Bind("RecipientName") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="deligvDDLRecipientName" runat="server" ClientIDMode="Static"
data-placeholder="Choose delegate…" class="chosen-single">
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:Label ID="deligvLblActive" runat="server" Text='<%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="deligvDDLActive" runat="server" Text='<%# (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>'>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="deligvDDLActiveInsert" runat="server">
<asp:ListItem Selected="True">Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="deligvEditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit" CssClass="gridActionbutton">
</asp:Button>
<asp:Button ID="deligvDeleteButton" runat="server" CausesValidation="False" CommandName="Delete" ClientIDMode="Static"
Text="Delete" CssClass="gridActionbutton" OnClientClick="return confirm('Are you sure you want to delete this Delegate Information?')" >
</asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="deligvUpdateButton" runat="server" CausesValidation="False" CommandName="Update"
Text="Update" CssClass="gridActionbutton"></asp:Button>
<asp:Button ID="deligvCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" CssClass="gridActionbutton"></asp:Button>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="deligvAddButton" runat="server" CommandName="Add" Text="Add Delegate" Width="90%" CausesValidation="false"
CssClass="gridActionbutton">
</asp:Button>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<tr>
<th>Recipient ID</th>
<th>Delegate</th>
<th>Active</th>
<th>Action</th>
</tr>
<tr>
<td colspan="4" style="text-align:center;">
No Delegates were found for you. Delegates can be added by clicking the 'Add Delegate' Button.
</td>
</tr>
<tr>
<td></td>
<td>
<asp:DropDownList ID="deligvDDLRecipientName" runat="server" ClientIDMode="Static"
data-placeholder="Choose delegate…" class="chosen-single">
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="deligvDDLActiveInsert" runat="server">
<asp:ListItem Selected="True">Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="deligvAddButtonEmpty" runat="server" CommandName="Add" Text="Add Delegate" Width="90%" CausesValidation="false"
CssClass="gridActionbutton">
</asp:Button>
</td>
</tr>
</EmptyDataTemplate>
</asp:GridView>
UPDATE
This is the code-behind that uses the same ID for the Gridview or the EmptyDataTemplate once it determines the row that it is coming from:
protected void DelegateInfoGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName.Equals("Add"))
{
//Get the Footer Controls that have the data
Control tFooterControls = getFooterControls(DelegateInfoGridView);
//Get the data for each control
int tiDelegateID = Convert.ToInt32((tFooterControls.FindControl("deligvDDLRecipientName") as DropDownList).SelectedValue);
bool tbIsActive = convertIsActiveValue((tFooterControls.FindControl("deligvDDLActiveInsert") as DropDownList).SelectedValue);
m_strUserID = CommonMethods.ParseUserID(User.Identity.Name);
//Insert into database
m_pagingClient.InsertDelegateInformation(m_strUserID, tiDelegateID, tbIsActive);
//Refresh the grid
populateDelegateInfoGrid();
}
}
catch (Exception ex)
{
//TO DO: Response.Redirect("~/Error.aspx");
}
}
UPDATE
I was able to get the IDs of the elements using the jquery below. However, it still does not solve my problem of updating the dropdowns.
$("input[id$=deligvDeleteButton]").click(function () {
$("[id*='deligvDDLRecipientName']").each(function () {
alert($(this).attr('id'));
$(this).val("").trigger("chosen:updated");
});
});
I was able to get the IDs of the elements using the jquery below. However, it still does not solve my problem of updating the dropdowns.
$("input[id$=deligvDeleteButton]").click(function () {
$("[id*='deligvDDLRecipientName']").each(function () {
alert($(this).attr('id'));
$(this).val("").trigger("chosen:updated");
});
});
I have a repeater control in my aspx page which has a textbox field called "name" and a hidden field called "id" that is the id of the name.
I want to get the value of the id field when the name textbox is in focus and pass it, can you please let me know how i can accomplish that?
<asp:Repeater ID="rpt" runat="server">
<ItemTemplate>
<tr>
<td >
<asp:TextBox ID="txtName" runat="server" Text='<%#Eval("Name")%>'/>
</td>
<td >
<asp:DropDownList ID="ddListNumber" runat="server">
<asp:ListItem Text='First' Value="1" />
<asp:ListItem Text='Second' Value="0" />
</asp:DropDownList>
</td>
<asp:HiddenField runat="server" Value='<%# Eval("ID") %>' ID="txtID" Visible="false" />
</tr>
</ItemTemplate>
</asp:Repeater>
I have a gridview and I want to display some data in the popup (popup should not be the ajax control).I was trying to do it by placing a gridview within gridview like:
<asp:GridView ID="grdInspectionApprovel" runat="server" Width="99%" EmptyDataText="<%$ Resources:Captions,grdEmptyPeriods%>"
AutoGenerateColumns="False" ShowFooter="true" Style="margin-bottom: 1px" CssClass="grdviewbrd"
OnRowDataBound="grdInspectionApprovel_RowDataBound" OnRowCommand="grdInspectionApprovel_RowCommand"
OnRowCreated="grdInspectionApprovel_RowCreated" OnRowEditing="grdInspectionApprovel_RowEditing">
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="emptyRow1" />
<PagerSettings Visible="false" />
<AlternatingRowStyle CssClass="AtlernatingRowStyle" />
<Columns>
<asp:TemplateField HeaderText="POPUP" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<div id="simplediv" style="background-color: White; border: 1px solid black; display: none;
width: 70%; height: 200px;">
<table width="100%">
<tr>
<td align="right">
<input type="image" src="~/App_Themes/MyWebTheme/images/imgError.gif" id="imageButton"
onclick="Popup.hide('simplediv');return false;" />
</td>
</tr>
<tr>
<td>
<asp:GridView ID="grdInspectionApprovelPOPUP" runat="server" Width="98%" EmptyDataText="<%$ Resources:Captions,grdEmptyPeriods%>"
AutoGenerateColumns="False" ShowFooter="true" Style="margin-bottom: 1px" CssClass="grdviewbrd">
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="emptyRow1" />
<PagerSettings Visible="false" />
<AlternatingRowStyle CssClass="AtlernatingRowStyle" />
<Columns>
<asp:TemplateField HeaderText="<%$ Resources:Captions,lblSupplierSINo%>" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:TextBox ID="txtSupplierSINo" runat="server" Text='<%# Eval("SupplierSerialNo") %>'
Width="150px"></asp:TextBox>
<headerstyle cssclass="gridtophead" />
<itemstyle horizontalalign="Center"></itemstyle>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="grid_title" />
</asp:GridView>
</td>
</tr>
<tr>
<td>
<asp:ImageButton runat="server" ID="deletebtn1" CommandName="btnSave" ImageUrl="<%$ Resources:Paths,imgBtnSave%>" />
<asp:LinkButton runat="server" ID="deletebtn" CommandName="btnSave" Text="Save"></asp:LinkButton>
<asp:Button ID="Button1" runat="server" Text="<%$ Resources:Captions,btnReset%>"
CssClass="btnStyle" />
</td>
</tr>
</table>
</div>
+
<asp:LinkButton runat="server" ID="linkbtnPopup" CommandName="callPopup" Text="++"
CommandArgument='<%# Eval("WOID") %>'></asp:LinkButton>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
<HeaderStyle CssClass="gridtophead" />
<ItemStyle HorizontalAlign="Right" Width="2%"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="<%$ Resources:Captions,lblSrNo%>" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblWO" Text='<%# Eval("WOID") %>' runat="server" Style="display: none;"></asp:Label>
<asp:Label ID="lblAssetID" Text='<%# Eval("AssetID") %>' runat="server" Style="display: none;"></asp:Label>
<%#(Convert.ToInt32(hfPageIndex.Value) * grdInspectionApprovel.PageSize) + Container.DataItemIndex + 1%>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
<HeaderStyle CssClass="gridtophead" />
<ItemStyle HorizontalAlign="Right" Width="2%"></ItemStyle>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="grid_title" />
</asp:GridView>
and Popup.show('simplediv') this function is from javascript file. I want to bind the chield gridview on each rowCommand of parent gridview and want to display this gridview on popup div.