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);
}
Related
I have a question about calling the pop-up registration ..
I want to correct the error for me regarding the pop-up window in my code ..
how can I call it in the VB code correctly to send email ?
And also show me this message " variable' is not declared" in the text boxes ..
What is the problem here?
Code as follows:
VB.net Code :
Protected Sub selectbtn_Click(sender As Object, e As EventArgs)
mpe.Show()
End Sub
Protected Sub SendEmail(sender As Object, e As EventArgs)
Dim EnglishName As String = TryCast(RepeaterCourse.FindControl("lblEnglishName"), Label).Text
Dim ArabicName As String = TryCast(RepeaterCourse.FindControl("lblCourseArabicTitle"), Label).Text
Dim StartCourse As String = TryCast(RepeaterCourse.FindControl("lblStartCours"), Label).Text
Dim EndCourse As String = TryCast(RepeaterCourse.FindControl("lblEndCourse"), Label).Text
Dim Days As String = TryCast(RepeaterCourse.FindControl("lblDays"), Label).Text
Dim CityCountry As String = TryCast(RepeaterCourse.FindControl("lblCountry"), Label).Text
Dim TextName As String = TextName.text
Dim body As String = "Email: " + TextBoxEmail.Text + "<br>" + "Name: " + TextBoxEnglishName.Text + "<br>" + "Country: " + DropDownListCountry.SelectedItem.ToString + "<br>" + "City: " + TextBoxCityName.Text + "<br>" + "Phone: " + TextBoxPhone.Text + "<br>" + "Category: " + DropDownListCategory.SelectedValue + "<br>" + "<br>" + "<br>" + "Message: " + TextComment.Text + "<br>" + hfEnglishName.Value
Dim mail As New System.Net.Mail.MailMessage()
mail.[To].Add("noor#gmail.com")
mail.Bcc.Add("noor#gmail.com")
mail.From = New MailAddress("noor#gmail.com")
mail.Subject = "From Inhouse Training ....By "
mail.Body = body
mail.IsBodyHtml = True
Dim smtp As New SmtpClient("relay-hosting.secureserver.net")
smtp.EnableSsl = False
smtp.UseDefaultCredentials = True
smtp.Send(mail)
LabelMSG.Text = "Sent Successfully"
ClearFields()
End Sub
<div id ="container">
<asp:UpdatePanel runat="server" id="UpdatePanel2" updatemode="Conditional">
<ContentTemplate>
<div class="row">
<div class="container">
<div style="text-align: center;margin-bottom: 10px;font-size: 16px;color: brown;"><asp:Label ID="lblmsg" Text="Registration Successful" runat="server" Visible="false" ></asp:Label></div>
<script type="text/javascript">
function HideLabel() {
var seconds = 5;
setTimeout(function () {
document.getElementById("<%=lblmsg.ClientID%>").style.display = "none";
}, seconds * 1000);
};
</script>
<div class="courses-listing clearfix" style="margin-bottom:30px;">
<asp:Repeater ID="RepeaterCourse" runat="server">
<ItemTemplate>
<div class="col-xs-12 col-sm-6 col-md-4 column threecol">
<div class="course-preview premium-course">
<div class="course-image">
<asp:Label ID="CourseLogo" runat="server" Text='<%# Eval("CourseLogo")%>'></asp:Label>
<%-- <div class="course-price product-price">
<div class="price-text"><span class="amount">$128</span></div>
<div class="corner-wrap">
<div class="corner"></div>
<div class="corner-background"></div>
</div>
</div>--%>
<div class="course-meta">
<header class="course-header">
<h5 class="nomargin"><asp:Label ID="lblEnglishName" runat="server" Text='<%# Eval("EnglishName")%>'></asp:Label></h5>
<br />
<%-- <span style="color: #777; font-size: 0.9em;">innovative tool to streamline the instructional design process.</span> <br />--%>
<h5 class="Arabic-Name"><asp:Label ID="lblCourseArabicTitle" runat="server" data-class="hide" Text='<%# Eval("ArabicName")%>'></asp:Label></h5>
<br />
<p class="author">
<asp:Label ID="lblStartCourse" data-class="hide" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "StartCourse", "{0:dd MMM}")%>'></asp:Label> -
<asp:Label ID="lblEndCourse" runat="server" data-class="hide" Text='<%# DataBinder.Eval(Container.DataItem, "EndCourse" , "{0:dd MMM yyyy}")%>'></asp:Label>
| <asp:Label ID="lblDays" runat="server" data-class="hide" Text='<%# Eval("Days")%>'></asp:Label> Days </p>
<asp:Label ID="lblCountry" data-class="hide" runat="server" Text='<%# Eval("CityCountry")%>'></asp:Label>
</header>
<br />
<div class="course-footer clearfix">
<%-- <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" OnClick="SavePDF" CommandArgument='<%# Eval("BrochoreLink")%>' class="sim-button button14" style="line-height: 20px; color:white;">Download Brochore</asp:LinkButton>--%>
<asp:Button ID="selectbtn" UseSubmitBehavior="false" runat="server" Text="Register" OnClick="selectbtn_Click1" class="sim-button button14" style="line-height: 20px; color:white;"></asp:Button>
<%-- <asp:LinkButton ID="SelectGo" runat="server" Text="Select" ItemStyle-Width="100" CommandName="Select" class="sim-button button14" style="line-height: 20px; color:white;">Register</asp:LinkButton>--%>
<a class="sim-button button14" style="line-height: 20px; color:white;" href='/Brochures/<%# Eval("BrochoreLink")%>' target="_blank" ><span>Download Brochore</span></a>
<%-- <a class="sim-button button14" style="line-height: 20px; color:white;" href="http://store.cglobalc.com/?page_id=1191"><span></span>Register</a>--%>
<a class="sim-button button14" style="line-height: 20px; color:white;" href="InHouseTraining.aspx" target="_blank"><span>Run This Course In-House</span></a>
</div>
</div>
</div>
</div>
<asp:LinkButton Text="" ID="lnkFake" runat="server" />
<cc1:ModalPopupExtender ID="mpe" runat="server" PopupControlID="pnlPopup" TargetControlID="lnkFake"
CancelControlID="btnClose" BackgroundCssClass="modalBackground" >
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopup" runat="server" Class="modalPopup" Style="display: none">
<div class="footer" align="right" style="float: right;">
<asp:Button ID="btnClose" runat="server" UseSubmitBehavior="false" Text="x" Style="margin: 2px;
font-size: 22px; color: white; background: none; border: none; border-color: none;
border-radius: 0px;" />
</div>
<div class="login">
<div class="login-header">
<p style="font-size: 30px; font-family: 'Lato', sans-serif; display: block; border-bottom: 1px solid rgba(255, 255, 255, 0.3);
margin: 0 0 0.1em 0; padding-bottom: 20px;">
CONTACT US
</p>
<p style="font-family: 'Lato', sans-serif; font-size: 1.25em; margin: 1em 0 0.4em 0;">
Fill out the form below to complete register!</p>
</div>
<div class="login-form">
<p class="left">
<asp:Label ID="Label1" runat="server" Text="Full Name" CssClass="login-label"></asp:Label>
<asp:TextBox ID="TextBoxName" runat="server" placeholder="Your Name" class="input"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="Register"
runat="server" ErrorMessage="*" ControlToValidate="TextBoxName" Forecolor="red"></asp:RequiredFieldValidator>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBoxName" ErrorMessage="Only character"
ValidationExpression="[a-zA-Z]+" Display="dynamic" Forecolor="red" Font-Size ="Small"></asp:RegularExpressionValidator>--%>
</p>
<p style="float: right;">
<asp:Label ID="Label2" runat="server" Text="Email" CssClass="login-label"></asp:Label>
<asp:TextBox ID="TextBoxEmail" runat="server" placeholder="Example#gmail.com" class="input"></asp:TextBox>
<br />
<asp:RegularExpressionValidator ID="valRegEx" ValidationGroup="Register" runat="server"
ControlToValidate="TextBoxEmail" ValidationExpression=".*#.*\..*" ErrorMessage="*Invalid Email address."
Display="dynamic" Forecolor="red" Font-Size ="Small">
</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ValidationGroup="Register"
ErrorMessage="*" ControlToValidate="TextBoxEmail"></asp:RequiredFieldValidator>
</p>
<p class="left">
<asp:Label ID="Label3" runat="server" Text="Country" CssClass="login-label"></asp:Label>
<asp:TextBox ID="TextBoxCityName" runat="server" placeholder="Your Country" class="input"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="Register"
runat="server" ErrorMessage="*" ControlToValidate="TextBoxCityName" Forecolor="red"></asp:RequiredFieldValidator>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="TextBoxCityName" ErrorMessage="Only character"
ValidationExpression="[a-zA-Z]+" Display="dynamic" Forecolor="red" Font-Size ="Small"></asp:RegularExpressionValidator>--%>
</p>
<p style="float: right;">
<asp:Label ID="Label4" runat="server" Text="Phone Number" CssClass="login-label"></asp:Label>
<asp:TextBox ID="TextBoxPhone" runat="server" placeholder="Your Phone" class="input"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="Register"
runat="server" ErrorMessage="*" ControlToValidate="TextBoxPhone" ValidateEmptyText="true"
ValidationExpression="^([0-9\(\)\/\+ \-]*)$" Forecolor="red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RxvMobile" ValidationGroup="Register"
runat="server" ErrorMessage="just number" ControlToValidate="TextBoxPhone" ValidateEmptyText="false"
ValidationExpression="^([0-9\(\)\/\+ \-]*){5,9}$" Forecolor="red" Display="Dynamic" Font-Size ="Small"></asp:RegularExpressionValidator>
</p>
<p class="left">
<asp:Label ID="Label5" runat="server" Text="Comment" CssClass="login-label"></asp:Label>
<asp:TextBox ID="TextBoxComment" runat="server" placeholder="Notes" TextMode="MultiLine"
Rows="4" class="login-textarea"></asp:TextBox><br />
</p>
<p>
<asp:Button ID="Button1" UseSubmitBehavior="false" ValidationGroup="Register" runat="server"
Text="Register" CommandName="Select" class="btn btn-primary" OnClick="SendEmail"
Style="cursor: pointer; border-radius: 5px; box-shadow: none; margin-left: auto;
margin-right: auto; display: block; vertical-align: top;" />
</p>
</div>
</div>
</asp:Panel>
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
</div>
Thank you ..
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;
}
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:
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>
I have a 4 page ASP.NET form which is storing data in the session. All this is working fine but I'm having a problem retreiving the value the user initial selected from my dropdown list.
1st Page HTML With DropDownList
<asp:DropDownList ID="ddlInnoc" runat="server" class="form-control">
<asp:ListItem Value="0">- - Please Select - -</asp:ListItem>
<asp:ListItem Value="Male">Male</asp:ListItem>
<asp:ListItem Value="Female">Female</asp:ListItem>
</asp:DropDownList>
1st Page Code Behind Which Re-displays Selected Value
protected void Page_Load(object sender, EventArgs e)
{
if (txtData1.Text == string.Empty && Session["pg1input"] != null)
{
txtData1.Text = Session["pg1input"].ToString();
}
if (ddlInnoc.SelectedValue == string.Empty && Session["pg1dd"] != null)
{
ddlInnoc.SelectedValue = Session["pg1dd"].ToString();
}
}
protected void pg1button_Click(object sender, EventArgs e)
{
Session["pg1input"] = txtData1.Text;
Session["pg1dd"] = ddlInnoc.SelectedValue;
Response.Redirect("/Session/pg2.aspx");
}
Page 3 HTML Code
<div class="form-group">
<div class="col-xs-12">
<asp:Label ID="Label1" class="col-md-2 control-label" runat="server" Text="Name:"></asp:Label>
<div class="col-md-3 form-control-static">
<%=Session["pg1input"] %>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<asp:Label ID="Label2" class="col-md-2 control-label" runat="server" Text="Sex:"></asp:Label>
<div class="col-md-3 form-control-static">
<%=Session["pg1dd"] %>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-offset-4 col-xs-12">
<asp:LinkButton ID="pg1EditButton" runat="server" OnClick="pg1EditButton_Click" CssClass="btn btn-default">
<span aria-hidden="true" class="glyphicon glyphicon-pencil"></span> Edit
</asp:LinkButton>
</div>
</div>
Page 3 Edit Button Code Behind
protected void pg1EditButton_Click(object sender, EventArgs e)
{
Response.Redirect("/Session/pg1.aspx");
}
I think condition if (ddlInnoc.SelectedValue == string.Empty is incorrect becuase initial value of ddlInnoc.SelectedValue will be 0 and not the String.Empty..try checking initial value as "0"
To fix the issue it added
if (ddlInnoc.SelectedValue != "0" && Session["pg1dd"] != null)
{
ddlInnoc.SelectedValue = Session["pg1dd"].ToString();
}