TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shijohn joseph
NA
17
3k
Two ComboBox Change values with seleted Value Changed
Nov 18 2011 12:16 AM
Hi sir,
i have two combobox named comboTravelAgentLocation,comboTravelAgentName,when i change item from the agentloaction combobox i have to get back the agentsname from the particular area only and when i change the agent name i have to fill the values to the agent details form
here below the code please can you check and fix the error !..
public void FillTravelAgentLocation()
{
DataSet dsTAgentLoc = new DataSet();
dsTAgentLoc = Obj_Class.UserInfo("select Agent_Location from Travel_Agents where Agent_Name<>'NONE'");
DataRow dr = dsTAgentLoc.Tables[0].NewRow();
dr[0] = "--Select--";
dsTAgentLoc.Tables[0].Rows.InsertAt(dr, 0);
comboTravelAgentLocation.DataSource = dsTAgentLoc.Tables[0];
comboTravelAgentLocation.DisplayMember = "Agent_Location";
comboTravelAgentLocation.SelectedIndex = 0;
comboTravelAgentLocation.ValueMember = "Agent_Location";
comboTravelAgentLocation.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.Never;
dsTAgentLoc.Dispose();
}
private void comboTravelAgentLocation_SelectedValueChanged(object sender, EventArgs e)
{
if (comboTravelAgentLocation.SelectedIndex!=0 )
{
int Index = comboTravelAgentLocation.SelectedIndex;
string AgentLoc = comboTravelAgentLocation.SelectedValue.ToString();
FillTravelAgentName(AgentLoc);
}
}
public void FillTravelAgentName(string AgentLoc)
{
DataSet dsAgentName = new DataSet();
if (AgentLoc == "")
{
dsAgentName = Obj_Class.UserInfo("select Agent_Name from Travel_Agents where Agent_Location<>'NONE'");
DataRow drAgentName = dsAgentName.Tables[0].NewRow();
drAgentName[0] = "--Select--";
dsAgentName.Tables[0].Rows.InsertAt(drAgentName, 0);
}
else
{
dsAgentName = Obj_Class.UserInfo("select Agent_Name from Travel_Agents where Agent_Location='" + AgentLoc + "'");
DataRow drAgentName = dsAgentName.Tables[0].NewRow();
drAgentName[0] = "--Select--";
dsAgentName.Tables[0].Rows.InsertAt(drAgentName, 0);
}
comboTravelAgentName.DataSource = dsAgentName.Tables[0];
comboTravelAgentName.DisplayMember = "Agent_Name";
comboTravelAgentName.ValueMember = "Agent_Name";
comboTravelAgentName.SelectedIndex = 0;
dsAgentName.Dispose();
}
private void comboTravelAgentName_SelectedValueChanged(object sender, EventArgs e)
{
if (comboTravelAgentLocation.SelectedIndex != 0 && comboTravelAgentName.SelectedIndex != 0)
{
string AgentLocation = comboTravelAgentLocation.SelectedValue.ToString();
string AgentName = comboTravelAgentName.SelectedValue.ToString();
DataSet dsAgentDtls = new DataSet();
dsAgentDtls = Obj_Class.UserInfo("select Agent_Code,Agent_Phone,Agent_Email,Agent_Web,Agent_Address from Travel_Agents where Agent_Name='" + AgentName + "' and Agent_Location='" + AgentLocation + "'");
if (dsAgentDtls.Tables[0].Rows.Count > 0)
{
txttAgentPhone.Text = dsAgentDtls.Tables[0].Rows[0][1].ToString();
txtAgentEmail.Text = dsAgentDtls.Tables[0].Rows[0][2].ToString();
txtAgentWeb.Text = dsAgentDtls.Tables[0].Rows[0][3].ToString();
txtAgentAddress.Text = dsAgentDtls.Tables[0].Rows[0][4].ToString();
}
}
}
Reply
Answers (
4
)
Script Help .net
Regular Expression for User Name