Exemple #1
0
    public void loaddata()
    {
        try
        {
            strConnection.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = strConnection;
            cmd.CommandText = "SELECT  * FROM         dbo.StateMaster inner join CityMaster on StateMaster.StateId=CityMaster.StateId  ";
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();
            da.Fill(ds);
            GridCity.DataSource = ds;

            GridCity.DataBind();
            cmd.Dispose();
            strConnection.Close();
        }
        catch
        {
        }
        finally
        {
            strConnection.Close();
        }
    }
Exemple #2
0
    private void FillGrid()
    {
        try
        {
            StrSql        = new StringBuilder();
            StrSql.Length = 0;
            StrSql.AppendLine("Select CM.Id,CM.CityName,CM.StateId,SM.StateName");
            StrSql.AppendLine(",SM.CountryId,CntM.CountryName");
            StrSql.AppendLine("From City_Mast CM");
            StrSql.AppendLine("Inner Join State_Mast SM On CM.StateId=SM.Id");
            StrSql.AppendLine("Inner Join Country_Mast CntM On CM.CountryId=CntM.Id");
            StrSql.AppendLine("Order By CM.CityName,SM.StateName,CntM.CountryName");

            dtTemp = new DataTable();
            dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString());

            GridCity.DataSource = dtTemp;
            GridCity.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }