Beispiel #1
0
    public void loaddata()
    {
        try
        {
            strConnection.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = strConnection;
            cmd.CommandText = "SELECT  * FROM         dbo.StateMaster ";
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();
            da.Fill(ds);
            GridState.DataSource = ds;

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

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

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