Hello
In my project am using a combobox to display all the fields from db( from different tables using view) .Here the problem is that For eg: Combobox name SID.SID contains two values 1 and 2.When we select the value: 1 it displays the Name filed,but when we change the selection to value: 2,the name field will not change .It remains the same.So how can i rectify this?
BAL Code for getting values from db
-----------------------------------
public static DataTable GetAllDetails_Edit(int sid)
{
const string selectALL_ById = "exec[Select_By_Id_EditRegi]@SID";
DAL.Method method = new DAL.SqlDataBase();
method.SelectQuery(selectALL_ById);
method.AddParameter("@SID", sid);
DataTable cdTable = method.GetDataTable();
method.Dispose();
return cdTable;
}
ComboBox IndexchangedCode
--------------------------
<pre lang="c#">private void cmbsid_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (cmbsid.Text.Trim() != "")
{
pd.SID = Convert.ToInt32(cmbsid.SelectedValue);
DataTable dt = PersonelMethod.GetAllDetails_Edit(pd.SID);
if (dt.Rows.Count > 0)
{
txtFname.Text = dt.Rows[dt.Rows.Count - 1][1].ToString();
}
}
}
catch (Exception ex)
{
CommonFunctions.Error(ex.ToString());
}
}
View Code
------------
<blockquote class="FQ"><div class="FQA">Quote:</div>ALTER PROCEDURE [dbo].[Select_By_Id_EditRegi]
@SID int
AS
BEGIN
SELECT dbo.tbl_Personel.SID, dbo.tbl_Personel.FName, dbo.tbl_Personel.MName, dbo.tbl_Personel.LName, dbo.tbl_Personel.DOB, dbo.tbl_Personel.Sex,
dbo.tbl_Personel.Age, dbo.tbl_Personel.Address, dbo.tbl_Personel.SponserName, dbo.tbl_Personel.EntryDate, dbo.tbl_others.SID AS Expr1,
dbo.tbl_others.FamCond, dbo.tbl_others.FamNotes, dbo.tbl_others.Status, dbo.tbl_Family.FathName, dbo.tbl_Family.MothName, dbo.tbl_Family.Fam1,
dbo.tbl_Family.Fam2, dbo.tbl_Family.Fam3, dbo.tbl_Family.Fam4, dbo.tbl_Family.Fam5, dbo.tbl_Family.Fam6, dbo.tbl_Family.Fam7,
dbo.tbl_Family.Fam8, dbo.tbl_Family.SID AS Expr2
FROM dbo.tbl_Family INNER JOIN
dbo.tbl_Personel ON dbo.tbl_Family.SID = dbo.tbl_Personel.SID INNER JOIN
dbo.tbl_others ON dbo.tbl_Personel.SID = dbo.tbl_others.SID
Where @SID=@SID