hello;
how can i get charges of desire element of dropdownlist in my textbox .for e.g, if i selected sugery the charges of surgery display automatically in my textbox when i selected surgery. i am sending my code n scenarion image. one thing, i will tell you . i am not understanding i write this code in which place either behind the button or form load.
regards
sumaira manzoor
Loading

Satyapriya NayakPosted Jan 25, 2012, 10:30 AM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace WebApplication5
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.AutoPostBack = true;
SqlConnection con = new SqlConnection(strConnString);
if (!IsPostBack)
{
DropDownList1.Items.Add("Choose type");
con.Open();
str = "select * from hospital";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
DropDownList1.Items.Add(reader["type"].ToString());
}
reader.Close();
con.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = "";
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from hospital where type='" + DropDownList1.SelectedItem.Text + "'";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
TextBox1.Text = reader["amount"].ToString();
}
reader.Close();
con.Close();
}
}
}
Thanks
sumaira manzoor hussain khanPosted Jan 26, 2012, 1:46 AM
i donot have any idea about crystal reporting in c# with asp.net. i donot know how we can establish dataset and connection in reporting. i took help of many tutoiral from the net. but i am not understanding about crystal reporting. i want to generate report on the behave patient reg code or patient visit id.
regards
sumaira manzoor
Satyapriya NayakPosted Jan 26, 2012, 1:44 AM
protected void Page_Load(object sender, EventArgs e)
{
TextBox_pv_date.Text= System.DateTime.Now.ToLongDateString();
OPD_TREATMENT_LIST.AutoPostBack = true;
if (!IsPostBack)
{
DropDownList_patient_reg_code.Items.Add("");
SqlCommand cmd = new SqlCommand("select * from [clinic patient registartion]", connection.get());
SqlDataReader read = cmd.ExecuteReader();
while (read.Read())
{
DropDownList_patient_reg_code.Items.Add(read["patient reg code"].ToString());
}
read.Close();
OPD_TREATMENT_LIST.Items.Clear();
OPD_TREATMENT_LIST.Items.Add("Choose treatments");
string str1 = "select * from [clinic treatments]";
command com = new SqlCommand(str1, connection.get());
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
OPD_TREATMENT_LIST.Items.Add(reader["treatment name"].ToString());
}
reader.Close();
}
}
protected void OPD_TREATMENT_LIST_SelectedIndexChanged(object sender , EventArgs e)
{
TextBox_OPD_TREATMENT_CHARGES.Text = "";
string str2 = "select * from [clinic treatments] where [treatment name]='" +OPD_TREATMENT_LIST.SelectedItem.Text + "'";
SqlCommand com2 = new SqlCommand(str2, connection.get());
sqlDataReader reader2 = com2.ExecuteReader();
while (reader2.Read())
{
TextBox_OPD_TREATMENT_CHARGES.Text = reader2["charges"].ToString();
}
reader2.Close();
}
Thanks
sumaira manzoor hussain khanPosted Jan 26, 2012, 1:28 AM
yes i got a solution of this issue. change the name of drop list . the real name of this dropdown is OPD_TREATMENT_LIST.SelectedItem.Text. i wrote wrong name of dropdownlist.
sumaira manzoor hussain khanPosted Jan 26, 2012, 1:05 AM
sir, there are some issue again appearing in my dropdownlist. if i select opd treatment like surgery,medicine,glasses etc. always one charges of desire treatments select. i am sending my code. your code and my code is same. but your code is perfetly given output and my code always given 8500 charges if i select any treatment.
Satyapriya NayakPosted Jan 25, 2012, 11:46 PM
God Bless you and your family.
sumaira manzoor hussain khanPosted Jan 25, 2012, 11:28 PM
Satyapriya NayakPosted Jan 25, 2012, 7:02 AM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Dropdownlist_click_data_in_textbox._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Dropdownlist_click_data_in_textbox
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.AutoPostBack = true;
SqlConnection con = new SqlConnection(strConnString);
if (!IsPostBack)
{
DropDownList1.Items.Add("Choose surgery");
con.Open();
str = "select * from test";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
DropDownList1.Items.Add(reader["surgery"].ToString());
}
reader.Close();
con.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from test where surgery='" + DropDownList1.SelectedItem.Text + "'";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
TextBox1.Text = reader["charges"].ToString();
}
reader.Close();
con.Close();
}
}
}
Thanks
Pravin GhadgePosted Jan 25, 2012, 6:53 AM
use
DropDownList1_SelectedIndexChanged event