How do I align my 2nd column textbox to the first one with label in Bootstrap? Here's my current code:
<div class="form-group">
<div class="col-md-6">
<asp:Label ID="lblFullName" runat="server" Text="Full Name" AssociatedControlID="txtFirstName" CssClass="control-label"></asp:Label>
<asp:TextBox ID="txtFirstName" runat="server" CssClass="form-control" placeholder="First Name"></asp:TextBox>
</div>
<div class="col-md-6">
<asp:TextBox ID="txtLastName" runat="server" CssClass="form-control" placeholder="Last Name"></asp:TextBox>
</div>
</div>
You create two rows:
<div class="form-group container">
<div class="row">
<div class="col-md-6">
<asp:Label ID="lblFullName" runat="server" Text="Full Name" AssociatedControlID="txtFirstName" CssClass="control-label"></asp:Label>
</div>
<div class="col-md-6"/>
</div>
<div class="row">
<div class="col-md-6">
<asp:TextBox ID="txtFirstName" runat="server" CssClass="form-control" placeholder="First Name"></asp:TextBox>
</div>
<div class="col-md-6">
<asp:TextBox ID="txtLastName" runat="server" CssClass="form-control" placeholder="Last Name"></asp:TextBox>
</div>
</div>
</div>
Related
<asp:Repeater ID="RptSCart" runat="server" OnItemCommand="RptSCart_ItemCommand" Visible="false">
<HeaderTemplate>
<div class="row text-center align-items-center" style="background-color: pink; height: 70px; color: black">
<div class="col-md-2"></div>
<div class="col-md-2">
<p>Product</p>
</div>
<div class="col-md-2">
<p>Price</p>
</div>
<div class="col-md-2">
<p>Stitch Cost</p>
</div>
<div class="col-md-1">
<p>Quantity</p>
</div>
<div class="col-md-2">
<p>Total</p>
</div>
<div class="col-md-1"></div>
</div>
<br />
</HeaderTemplate>
<ItemTemplate>
<div class="row text-center align-items-center">
<div class="col-md-2 ">
<asp:Image ID="PImage" runat="server" ImageUrl='<%#Bind("Pic")%>' CssClass="img image-prod" Width="100" Height="150" />
</div>
<div class="col-md-2">
<asp:Label ID="LabelPName" runat="server" CssClass="product-name" Text='<%#Bind("PName")%>' ForeColor="Black"></asp:Label>
</div>
<div class="col-md-2">
<asp:Label ID="LabelPPrice" runat="server" CssClass="price" Text='<%#Bind("SPrice") %>' ForeColor="Black"></asp:Label>
</div>
<div class="col-md-2">
<asp:Label ID="lblSPrice" runat="server" CssClass="price" Text='<%#Bind("STPrice") %>' ForeColor="Black"></asp:Label>
</div>
<div class="col-md-1">
<asp:Label ID="Label1" runat="server" CssClass="price" Text="1" ForeColor="Black"></asp:Label>
</div>
<div class="col-md-2">
<asp:Label ID="lblTotal" CssClass="total" runat="server" Text='<%#Bind("Amount") %>' ForeColor="Black"></asp:Label>
</div>
<div class="col-md-1">
<asp:LinkButton ID="lnkRemove" runat="server" CssClass="product-remove" CommandName="Delete"><span class="ion-ios-close-circle"></span></asp:LinkButton>
</div>
</div>
<h1>
<hr />
</h1>
</ItemTemplate>
</asp:Repeater>
DataTable dt1 = (DataTable)Session["Stitch_Cart"];
RptSCart.DataSource = dt1;
RptSCart.DataBind();
RptSCart.Visible = true;
Here is my repeater in which i bind data (products added in cart by customer) from data table. On click of remove button i want to delete row from data table using data table row index instead of repeater index.If quantity of product(xyz) is 2 i am creating two rows in cart and data table (it is according to my requirement). If user wants to remove one, the other one should not be deleted.
Since I'm using many viewstates, I'm trying to stop relying on them because pages take forever to load. I have this repeater with a table and when I click a button it enables a form that has another repeater. I need to pass the ID of the row of the 1st repeater so i can update the data related to that item on submit button.
Note. The ID i need is on the 1st column of repeater
<td>
<asp:Label ID="lblIdRegisto" runat="server" Text='<%# Eval("ID_Registo") %>' Style="display: none;" />
<asp:Label ID="lblReferenciaCliente" runat="server" Text='<%# Eval("Ref_Cliente") %>' />
</td>
here is my code
this is my submit button
protected void btnValidarFormulario_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string cnnStr = ConfigurationManager.ConnectionStrings["ValidacaoFormas_ConnectionString"].ConnectionString;
ADefinicao def = new ADefinicao();
def.ReferenciaInterna = txtRefInterna.Text;
def.Indice = txtIndice.Text;
def.Observacoes = txtObservacoes.Text;
def.isValid = "Sim";
def.DataValidacao = DateTime.Now.ToString("dd-MM-yyyy").ToString();
string nome = Session["Nome"].ToString();
int id = Convert.ToInt32(ViewState["id"]);
id = ADefinicao.UpdateADefinicao(nome, id, def);
ScriptManager.RegisterStartupScript(this, this.GetType(), "key_name", "ShowToast('success','Documento validado com sucesso.'); setTimeout(function(){window.location.href ='/Conta/Início.aspx'}, 3000);", true);
}
}
and this is the main repeater
<asp:Repeater ID="rptValidacao" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="rptValidacao_ItemCommand">
<HeaderTemplate>
<table id="tblValidarRegistos" class="table table-bordered table-striped table-hover dataTable text-center">
<thead class="thead-dark">
<tr>
<th class="text-center">Ref. Cliente</th>
<th class="text-center">Ref. Interna</th>
<th class="text-center">Índice</th>
<th class="text-center">Qtd. Formas</th>
<th class="text-center"></th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr style="font-size:15px;">
<td>
<asp:Label ID="lblIdRegisto" runat="server" Text='<%# Eval("ID_Registo") %>' Style="display: none;" />
<asp:Label ID="lblReferenciaCliente" runat="server" Text='<%# Eval("Ref_Cliente") %>' />
</td>
<td>
<asp:Label ID="lblReferenciaInterna" runat="server" Text='<%# Eval("Ref_Interna") %>' />
</td>
<td>
<asp:Label ID="lblIndicie" runat="server" Text='<%# Eval("Indice") %>' />
</td>
<td>
<asp:Label ID="lblQTDFormas" runat="server" Text='<%# Eval("QTD_Formas") %>' />
</td>
<td>
<asp:ImageButton ID="ibtnValidar" runat="server" ImageUrl="/Images/Icones/success.png" CommandName="Validar" CommandArgument='<%# Eval("ID_Registo") %>' Width="25" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I was wondering if is there a way to pass an arguent from that repeater to this button
<asp:Button ID="btnValidarFormulario" CssClass="submit-button font-weight-bold" runat="server" Text="Validar Documentação" ValidationGroup="vgValidarDocumentacao" OnClick="btnValidarFormulario_Click" />
EDIT.
This the the form that appears when img button clicked on repeater with some data and needs to be updated, it's a bit long so i only posted cause i was asked. The submit button is at the end. I only need the ID where all the data on the form comes from and pass it to the submit button
<div id="divValidar" class="card card-danger shadow mx-auto custom-card-layout" visible="false" runat="server" style="min-width: 600px; max-width: 950px;">
<div class="card-header text-center custom-card-header">
<h3 class="card-title font-weight-bold">A - Definição</h3>
</div>
<!-- /.card-header -->
<!-- form start -->
<div class="card-body">
<div class="container">
<asp:ValidationSummary runat="server"
ID="ValidationSummary2"
DisplayMode="BulletList"
HeaderText="<b>Preencha todos os campos devidamente para proseguir.</b>"
ValidationGroup="vgADefinicao"
CssClass="alert validation-summary"
ShowSummary="true" />
<fieldset>
<legend>Informação Referêncial</legend>
<div class="row justify-content-center">
<div class="col-sm-4">
<div class="form-group col-10 mx-auto text-center">
<asp:Label ID="lblRefCliente" Text="1. Referência Cliente" AssociatedControlID="txtRefCliente" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<asp:TextBox ID="txtRefCliente" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
</div>
</div>
<div class="col-sm-4">
<div class="form-group col-10 mx-auto">
<asp:Label ID="lblRefInterna" Text="2. Referência Interna" AssociatedControlID="txtRefInterna" runat="server"></asp:Label>
<asp:TextBox ID="txtRefInterna" CssClass="form-control form-control-sm border border-dark" runat="server" placeholder="Referência Interna"></asp:TextBox>
</div>
</div>
<div class="col-sm-4">
<div class="form-group col-10 mx-auto">
<asp:Label ID="lblIndice" Text="3. Índice" AssociatedControlID="txtIndice" runat="server"></asp:Label>
<asp:TextBox ID="txtIndice" CssClass="form-control form-control-sm border border-dark" runat="server" placeholder="Indíce"></asp:TextBox>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Casquilhos e Formas - Quantidade</legend>
<div class="row justify-content-center pb-4">
<div class="col-md-6">
</div>
<div class="col-md-6 text-center">
<strong>5. Quantidade de Casquilhos</strong>
</div>
</div>
<div class="row justify-content-center row-eq-height">
<div class="col-md-6">
<div class="form-group col-7 mx-auto text-center">
<asp:Label ID="lblQtdFormas" Text="4. Quantidade de Formas" AssociatedControlID="txtQtdFormas" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<asp:TextBox ID="txtQtdFormas" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
</div>
</div>
<div class="col-md-6">
<div class="form-group col-7 mx-auto text-center">
<asp:Label ID="lblCasquilhosFixos" Text="5.1 Fixos" AssociatedControlID="txtCasquilhosFixos" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<asp:TextBox ID="txtCasquilhosFixos" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
</div>
<div class="form-group col-7 mx-auto text-center">
<asp:Label ID="lblCasquilhosLivres" Text="5.2 Livres" AssociatedControlID="txtCasquilhosLivres" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<asp:TextBox ID="txtCasquilhosLivres" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Casquilhos e Formas - Diâmetros</legend>
<div class="row justify-content-center pb-4">
<div class="col-md-6 text-center">
<strong>6. Diâmetro dos casquilhos</strong>
</div>
<div class="col-md-6 text-center">
<strong>7. Diâmetro das formas</strong>
</div>
</div>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDiametroCasqLadoFixo" Text="6.1 Lado Fixo" AssociatedControlID="txtDiametroCasqLadoFixo" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtDiametroCasqLadoFixo" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDiametroCasqLadoMovel" Text="7.2 Lado Móvel" AssociatedControlID="lblDiametroCasqLadoMovel" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtDiametroCasqLadoMovel" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDiametroFormasFixo" Text="7.1 Lado fixo" AssociatedControlID="txtDiametroFormasFixo" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtDiametroFormasFixo" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDiametroFormasMovel" Text="7.2 Lado Móvel" AssociatedControlID="txtDiametroFormasMovel" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtDiametroFormasMovel" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDiametroFormasCorpo" Text="7.2 Corpo" AssociatedControlID="txtDiametroFormasCorpo" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtDiametroFormasCorpo" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Cru
<small>(A preencher pela Extrusão)</small>
</legend>
<div class="row justify-content-center pb-4">
<div class="col-md-6 text-center">
<strong>8. Informação do Cru</strong>
</div>
<div class="col-md-6 text-center">
<strong>8.3 Parâmetros do cru:</strong>
</div>
</div>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblCruBase" Text="8.1 Base" AssociatedControlID="txtCruBase" runat="server"></asp:Label>
<asp:TextBox ID="txtCruBase" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblCruLinha" Text="8.2 Linha" AssociatedControlID="txtCruLinha" runat="server"></asp:Label>
<asp:TextBox ID="txtCruLinha" CssClass="form-control form-control-smborder border-dark" runat="server" ReadOnly="true"></asp:TextBox>
</div>
<div class="form-group col-10 mx-auto text-center">
<asp:Label ID="lblMarcacaoContinua" Text="8.4 Marcação contínua" AssociatedControlID="txtMarcacaoContinua" runat="server" />
<small class="text-muted">(texto + cor)</small>
<asp:TextBox ID="txtMarcacaoContinua" TextMode="MultiLine" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true" />
</div>
</div>
<div class="col-md-6">
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblCruDiametro" Text="Diâmetro" AssociatedControlID="txtCruDiametro" runat="server"></asp:Label>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtCruDiametro" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblCruEspessura" Text="Espessura" AssociatedControlID="txtCruEspessura" runat="server"></asp:Label>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtCruEspessura" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblComprimento" Text="Comprimento" AssociatedControlID="txtComprimento" runat="server"></asp:Label>
<div class="input-group input-group-sm">
<asp:TextBox ID="txtComprimento" CssClass="form-control form-control-sm border border-dark" runat="server" ReadOnly="true"></asp:TextBox>
<div class="input-group-append border border-dark">
<span class="input-group-text"><strong>mm</strong></span>
</div>
</div>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>9. Datas Previstas</legend>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDataFormasPreSerie" runat="server" AssociatedControlID="txtReadOnlyDataFormasPreSerie" Text="9.1 Formas Pré-Série" />
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<div class="input-group-prepend border border-dark">
<span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
</div>
<asp:TextBox ID="txtReadOnlyDataFormasPreSerie" runat="server" class="form-control form-control-sm border border-dark" ReadOnly="true" />
</div>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDataFormasSerie" runat="server" AssociatedControlID="txtReadOnlyDataFormasSerie" Text="9.3 Formas Série" />
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<div class="input-group-prepend border border-dark">
<span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
</div>
<asp:TextBox ID="txtReadOnlyDataFormasSerie" runat="server" class="form-control form-control-sm border border-dark" ReadOnly="true" />
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDataAmostrasIniciais" runat="server" AssociatedControlID="txtReadOnlyDataAmostrasIniciais" Text="9.2 Amostras iniciais" />
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<div class="input-group-prepend border border-dark">
<span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
</div>
<asp:TextBox ID="txtReadOnlyDataAmostrasIniciais" runat="server" class="form-control form-control-sm border border-dark" ReadOnly="true" />
</div>
</div>
<div class="form-group col-6 mx-auto text-center">
<asp:Label ID="lblDataArranqueProducao" runat="server" AssociatedControlID="txtReadOnlyDataArranqueProducao" Text="9.4 Arranque Produção" />
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<div class="input-group input-group-sm">
<div class="input-group-prepend border border-dark">
<span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
</div>
<asp:TextBox ID="txtReadOnlyDataArranqueProducao" runat="server" class="form-control form-control-sm border border-dark" ReadOnly="true" />
</div>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Documentos</legend>
<div class="row justify-content-center">
<div class="col-md-12">
<asp:Repeater ID="rptAnexos" runat="Server" OnItemCommand="rptAnexos_ItemCommand">
<HeaderTemplate>
<table id="tblAnexos" class="table-sm table table-striped table-bordered text-center rounded" style="border-radius: 10px;">
<caption>Lista de Anexos</caption>
<thead class="thead-dark">
<tr>
<th>ID</th>
<th>Tipo Desenho</th>
<th>Nome Ficheiro</th>
<th>Inserido Por</th>
<th></th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr style="font-size:small">
<td>
<asp:Label ID="lblIdRegisto" runat="server" Text=' <%# Eval("ID_Registo") %>' />
</td>
<td>
<asp:Label ID="lblTipoDesenho" runat="server" Text=' <%# Eval("Tipo") %>' />
</td>
<td>
<asp:Label ID="lblNomeAnexo" runat="server" Text='<%# Eval("NomeAnexo") %>' />
</td>
<td>
<asp:Label ID="lblPiloto" runat="server" Text='<%# Eval("Piloto") %>' />
</td>
<td class="text-center">
<asp:ImageButton runat="server" ImageUrl="/Images/Icones/download.png" Width="20" CommandName="Download" CommandArgument='<%# Eval("ID") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</fieldset>
<fieldset>
<legend>Observações</legend>
<div class="row justify-content-center row-eq-height">
<div class="col-md-12">
<div class="form-group col-7 mx-auto text-center">
<asp:Label ID="lblObservacoes" Text="Observações" AssociatedControlID="txtObservacoes" runat="server"></asp:Label>
<i class="fas fa-asterisk text-danger mb-2" style="font-size: 8px;"></i>
<asp:TextBox ID="txtObservacoes" CssClass="form-control form-control-sm border border-dark" runat="server" TextMode="MultiLine" Rows="3"></asp:TextBox>
<div class="valid-feedback">Success! You've done it.</div>
<i class="glyphicon glyphicon-ok form-control-feedback"></i>
<div class="valid-feedback feedback-icon">
<i class="fa fa-check"></i>
</div>
<div class="invalid-feedback feedback-icon">
<i class="fa fa-times"></i>
</div>
<asp:CustomValidator ID="cvObservacoes" runat="server" EnableClientScript="True" ValidationGroup="vgValidarDocumentacao" Display="Dynamic" ValidateEmptyText="True" ClientValidationFunction="CustomValidator" CssClass="server-validator" ControlToValidate="txtObservacoes"></asp:CustomValidator>
<asp:RequiredFieldValidator ID="rfvObservacoes" runat="server" CssClass="server-validator" ValidationGroup="vgValidarDocumentacao" SetFocusOnError="True" ControlToValidate="txtObservacoes" Text="Campo necessário." ErrorMessage="<b>Observações:</b> Campo necessário." Display="Dynamic"></asp:RequiredFieldValidator>
</div>
</div>
</div>
</fieldset>
</div>
</div>
<!-- /.card-body -->
<div class="card-footer custom-card-footer">
<asp:Button ID="btnValidarFormulario" CssClass="submit-button font-weight-bold" runat="server" Text="Validar Documentação" ValidationGroup="vgValidarDocumentacao" OnClick="btnValidarFormulario_Click" />
</div>
<!-- /.card-footer -->
</div>
You can place a Label in an ItemTemplate and set the Visibility to false.
<asp:Repeater ID="rptValidacao" runat="server">
<ItemTemplate>
<asp:Label ID="LabelID" runat="server" Text='<%# Eval("id") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:Repeater>
But the Label still exists with the correct value if you use FindCOntrol in the Button Click event
protected void btnValidarFormulario_Click(object sender, EventArgs e)
{
Label lbl = rptValidacao.Items[i].FindControl("LabelID") as Label;
}
You should also look into DataKeys. But a Repeater cannot use them.
A solution is to create a HiddenField and on data bind of the repeater yourHiddenField.Value will be populated to something like:
3,4,7,12
and then on button click split the values in the hidden field. You can do this even on the client-side if the hidden field is populated via Javascript before submission is executed.
I have this html/marckup code
<div class="col-md-12 pre-scrollable">
<asp:repeater runat="server" ID="rptDataInputs">
<itemtemplate>
<div class="row">
<div class="form-group">
<label class="col-md-2 control-label" for="textinput"><asp:Literal ID="Literal22" Text='<%#DataBinder.Eval(Container.DataItem, "ID") %>' runat="server" /></label>
<div class="col-md-6">
<asp:textbox ID="tb_value" MaxLength="10" runat="server" class="form-control" style="margin-bottom:10px;" Text='<%#DataBinder.Eval(Container.DataItem, "Value") %>'/>
</div>
<div class="col-md-2">
<asp:CheckBox Text="" runat="server" Checked='<%#DataBinder.Eval(Container.DataItem, "Insert").Equals("1") %>'/>
</div>
<div class="col-md-2">
<label runat="server" id="lbl_break"><input runat="server" id="break" type="radio" name="optradio"></label>
</div>
</div>
</div>
</itemtemplate>
</asp:repeater>
</div>
i need to get the value in the radio for each line.
How could i do this?
I have a dropdown menu and it has a set of items.I want to hide a particular panel when i am clicking on a dropdown menu.
Below is my c# code and my panel is designed in asp.net.
I want to disable panel XII when i was clicking on dropdown list item Not Applicable in panel X
protected void ddsscboard_SelectedIndexChanged(object sender, EventArgs e)
{
try {
string sscpanel = ddsscboard.SelectedItem.Text;
panelshow(sscpanel);
}
catch(Exception ex)
{
}
}
public void panelshow(string sscpanel)
{
if (sscpanel == "Not Applicable")
XII.Visible = false;
else
lblmsg.Text = sscpanel;
}
}
panel:-
Class X
<div class="form-group">
<label>Select Board</label>
<asp:DropDownList ID="ddsscboard" CssClass="form-control" OnSelectedIndexChanged="ddsscboard_SelectedIndexChanged" runat="server">
<asp:ListItem>Not Applicable</asp:ListItem>
<asp:ListItem>SSC</asp:ListItem>
<asp:ListItem>CBSC</asp:ListItem>
<asp:ListItem>ICSC</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
</div>
<div class="form-group">
<label>Complition Month</label>
<asp:TextBox ID="txtssccomplitionmonth" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Complition Year</label>
<asp:TextBox ID="txtssccomplitionyear" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Marks Obtained</label>
<asp:TextBox ID="txtsscmarksobtained" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Total Marks</label>
<asp:TextBox ID="txtssctotalmarks" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Upload File</label>
<asp:FileUpload ID="sscfile" runat="server" />
</div>
</div>
<!-- /.col-lg-6 (nested) -->
</div>
<!-- /.row (nested) -->
</div>
</asp:Panel>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<div class="col-lg-12">
<asp:Panel ID="XII" runat="server" CssClass="panel panel-default">
<div class="panel-heading">
Class XII
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label>Select Board</label>
<asp:DropDownList ID="ddhscboard" CssClass="form-control" runat="server">
<asp:ListItem>Not Applicable</asp:ListItem>
<asp:ListItem>HSC</asp:ListItem>
<asp:ListItem>CBSC</asp:ListItem>
<asp:ListItem>ICSC</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
</div>
<div class="form-group">
<label>Complition Month</label>
<asp:TextBox ID="txthsccomplitionmonth" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Complition Year</label>
<asp:TextBox ID="txthsccomplitionyear" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Marks Obtained</label>
<asp:TextBox ID="txthscmarksobtained" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Total Marks</label>
<asp:TextBox ID="txthsctotalmarks" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label>Upload File</label>
<asp:FileUpload ID="hscfile" runat="server" />
</div>
</div>
<!-- /.col-lg-6 (nested) -->
</div>
<!-- /.row (nested) -->
</div>
</asp:Panel>
<!-- /.panel-body -->
</div>
You need to set the AutoPostBack attribute in your DropDownList to true. Note you may also want to establish a blank ListItem so "Not Applicable" is not Selected by default:
<asp:DropDownList AutoPostBack="true" ID="ddsscboard" CssClass="form-control" OnSelectedIndexChanged="ddsscboard_SelectedIndexChanged" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Not Applicable</asp:ListItem>
<asp:ListItem>SSC</asp:ListItem>
<asp:ListItem>CBSC</asp:ListItem>
<asp:ListItem>ICSC</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
I have set a bootstrap tab pane, within this tab pane there is a form, on asp:Button press the code will not execute.
I know the code works as when not in the tab pane it works every time.
But its for a user control page and would be better to provide function within the tab panes.
This is for all buttons within the tab pane.
if one gets solved then the method to repair others is made!
Here is the HTML markup:
<div class="tab-content col-lg-10">
<div class="tab-pane active" id="pane1">
<%--Content goes in here, so tables, and whatever else--%>
<h3>My Bookings</h3>
<div class="container">
<asp:GridView runat="server" ID="dgBookingView" AutoGenerateColumns="False" DataSourceID="myBookings" CssClass="table table-striped table-bordered" UseAccessibleHeader="True">
<Columns>
<asp:BoundField DataField="BookingID" HeaderText="Booking #" InsertVisible="False" SortExpression="BookingID" />
<asp:BoundField DataField="FilmName" HeaderText="Movie" SortExpression="FilmName" />
<asp:BoundField DataField="Requirements" HeaderText="Requirements" SortExpression="Requirements" />
<asp:BoundField DataField="Showtime" HeaderText="Time" SortExpression="Showtime" DataFormatString="{0:t}" />
<asp:BoundField DataField="ShowDate" HeaderText="Date" SortExpression="ShowDate" DataFormatString="{0:d}" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="myBookings" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT Booking.BookingID, Booking.CustomerFK, Booking.AuditorumFK, Booking.Requirements, Film.FilmName, Showtime.Showtime, Showtime.ShowDate, Showtime.AuditoriumID, Customers.UserNameFK FROM (((((Booking INNER JOIN Seat ON Booking.BookingID = Seat.BookingFK) INNER JOIN Auditorium ON Seat.AuditoriumFK = Auditorium.AuditoriumID) INNER JOIN Showtime ON Auditorium.AuditoriumID = Showtime.AuditoriumID) INNER JOIN Film ON Showtime.FilmFK = Film.FilmID) INNER JOIN Customers ON Booking.CustomerFK = Customers.CustomerID)
WHERE([Customers.UserNameFK] = ? )">
<SelectParameters>
<asp:SessionParameter
Name="userNamePa"
SessionField="userName"
DefaultValue="userName" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<div class="row">
<h3>Specify any Special Requirements</h3>
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">Booking #</label>
<div class="col-sm-6">
<asp:TextBox runat="server" CssClass="form-control" ID="txtBookingID"></asp:TextBox>
</div>
<div class="col-sm-4">
<h4>
<asp:RequiredFieldValidator ID="rqfUserNameValid" ControlToValidate="txtBookingID" runat="server"
ErrorMessage="Enter a Booking Number" CssClass="label label-danger">
</asp:RequiredFieldValidator>
</h4>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Extra Requirements</label>
<div class="col-sm-6">
<asp:TextBox ID="txtRequirements" class="form-control" Rows="5" runat="server"></asp:TextBox>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-6">
<asp:Button runat="server" CssClass="btn btn-default" Text="Make Change" ID="btnRequirements" OnClick="btnRequirements_OnClick" />
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="pane2" runat="server">
<%--Change User Password START--%>
<h3>Change Password</h3>
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">Current Password</label>
<div class="col-sm-6">
<asp:TextBox runat="server" CssClass="form-control" ID="txtCurrentPass" TextMode="Password"></asp:TextBox>
</div>
<div class="col-sm-4">
<h4>
<asp:RequiredFieldValidator runat="server" CssClass="label label-danger" ID="rqfCurrentPassword" ControlToValidate="txtCurrentPass"
ErrorMessage="Enter Current Password">
</asp:RequiredFieldValidator>
</h4>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">New Password</label>
<div class="col-sm-6">
<asp:TextBox runat="server" CssClass="form-control" TextMode="Password" ID="txtNewPassword"></asp:TextBox>
</div>
<div class="col-sm-4">
<h4>
<asp:RequiredFieldValidator runat="server" CssClass="label label-danger" ID="rqfNewPassword" ControlToValidate="txtNewPassword"
ErrorMessage="Required">
</asp:RequiredFieldValidator>
</h4>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Confirm Password</label>
<div class="col-sm-6">
<asp:TextBox runat="server" CssClass="form-control" TextMode="Password" ID="txtConfirmPassword"></asp:TextBox>
</div>
<div class="col-sm-4">
<h4>
<asp:RequiredFieldValidator runat="server" CssClass="label label-danger" ID="rqfConfirmPassword" ControlToValidate="txtConfirmPassword"
ErrorMessage="Required">
</asp:RequiredFieldValidator>
</h4>
<h4>
<asp:CompareValidator runat="server" ControlToValidate="txtConfirmPassword" ControlToCompare="txtNewPassword" ID="PassCompare" ErrorMessage="Confirm password must match password" CssClass="label label-danger"></asp:CompareValidator>
</h4>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-6">
<asp:Button runat="server" CssClass="btn btn-default" Text="Change Password" ID="btnPasswordChange" OnClick="btnChangePassword_OnClick"></asp:Button>
</div>
</div>
</div>
<div class="col-sm-4">
<h4>
<asp:Label runat="server" CssClass="label label-danger" ID="lblPassChange" Visible="False" Text=""></asp:Label>
</h4>
</div>
</div>
<%--Change User Password--%>
</div>
</div>
And the C# Code for button Event:
protected void btnChangePassword_OnClick(object sender, EventArgs eventArgs)
{
//Changes Password of current Logged in User
string oldPass = txtCurrentPass.Text;
string newPass = txtNewPassword.Text;
MembershipUser user = Membership.GetUser(User.Identity.Name);
if (txtCurrentPass.Text == txtNewPassword.Text)
{
lblPassChange.Visible = true;
lblPassChange.Text = "Old Password must not match New Password";
}
else
{
if (user != null && user.ChangePassword(oldPass, newPass))
{
lblPassChange.Visible = true;
lblPassChange.Text = "Password Changed Successfully";
lblPassChange.CssClass = "label label-success";
}
else
{
lblPassChange.Visible = true;
lblPassChange.Text = "Error, Please try again";
}
}
}
Where am i going wrong?
Any help would be appreciated