Hi,
How can I solve this problem:
I have button1 and button2 on my aspx page.
when button1 clicks, I showed button2 and dropdwonlist1 with values on my aspx page.
I wrote code in button1 click event like this:
Button button2=new button2();
button2.Visible= true;
DropDownList DL=new DropDownList();
DL.visible = true;
Here is my problem in button2 click event:
How can I get DL selected item text in button2 click event?
Advance Thanks!
Darma
Loading
Sanjeeb LenkaPosted Nov 4, 2013, 5:54 AM
try this sample:
in aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
in .cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Button2.Visible=false;
DropDownList1.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Button2.Visible = true;
DropDownList1.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue;
}
}
darma tejaPosted Nov 4, 2013, 6:01 AM
It works well.
HanookPosted Nov 4, 2013, 5:02 AM
http://www.aspsnippets.com/Articles/Send-Pass-Data-Values-from-one-page-to-another-using-jQuery.aspx
http://stackoverflow.com/questions/18269395/get-the-value-of-dropdown-on-asp-button-click
http://stackoverflow.com/questions/13331160/asp-net-dropdown-always-return-first-value-on-button-click-event
http://mrbool.com/common-dropdownlist-operation-in-asp-net-and-c/24586